Package org.apache.uima.ducc.transport.event.common

Examples of org.apache.uima.ducc.transport.event.common.IDuccProcess


          }
          IDuccProcessMap processMap = service.getProcessMap();
          Iterator<DuccId> iteratorP = processMap.keySet().iterator();
          while(iteratorP.hasNext()) {
            DuccId jpid = iteratorP.next();
            IDuccProcess jp = processMap.get(jpid);
            ProcessState processState = jp.getProcessState();
            switch(processState) {
            case Starting:
            case Initializing:
            case Running:
              NodeIdentity nodeIdentity = jp.getNodeIdentity();
              String key = nodeIdentity.getIp().trim();
              Integer value = new Integer(0);
              if(!properties.containsKey(key)) {
                properties.put(key, value);
              }
View Full Code Here


          DuccId jobid = job.getDuccId();
          IDuccProcessMap map = job.getProcessMap();
          Iterator<DuccId> procids = map.keySet().iterator();
          while(procids.hasNext()) {
            DuccId procid = procids.next();
            IDuccProcess proc = map.get(procid);
            if(!proc.isComplete()) {
              NodeIdentity nodeIdentity = proc.getNodeIdentity();
              String procNodeName = nodeIdentity.getName();
              if(procNodeName != null) {
                if(nodeName.equals(procNodeName)) {
                  JobProcessInfo jpi = new JobProcessInfo();
                  jpi.jobId = jobid;
View Full Code Here

     * and IP address. With that multiple agents can be launched on the same
     * physical machine simulating a cluster of nodes.
     *
     */
    public void launchProcess(String host, String ip, ICommandLine cmdLine) throws Exception {
        IDuccProcess process =
            new DuccProcess(duccIdFactory.next(), new NodeIdentity(ip, host));
        process.setProcessType(ProcessType.Pop);
        ManagedProcess managedProcess = new ManagedProcess(process, cmdLine, true);
        DuccCommandExecutor executor =
            new DuccCommandExecutor(cmdLine, host, ip, managedProcess);
        executorService.submit(executor);
    }
View Full Code Here

      String[] cmd = getDeployableCommandLine(cmdLine,processEnv);     
      if ( isKillCommand(cmdLine) ) {
        logger.info(methodName, null, "Killing process");
        stopProcess(cmdLine, cmd);
      } else {
        IDuccProcess duccProcess = ((ManagedProcess) managedProcess).getDuccProcess();
                // If running a real agent on a node, collect swap info and assign max swap usage threshold
        // for each process. In virtual mode, where there are multiple agents per node, we dont
        // set nor enforce swap limits.
        if ( !agent.virtualAgent) {
          // Calculate how much swap space the process is allowed to use. The calculation is based on
          // the percentage of real memory the process is assigned. The process is entitled the
          // same percentage of the swap.
          // Normalize node's total memory as it is expressed in KB. The calculation below is based on bytes.
          double percentOfTotal =  ((double)duccProcess.getCGroup().getMaxMemoryLimit())/
              (agent.getNodeInfo().getNodeMetrics().getNodeMemory().getMemTotal()*1024); // need bytes

         
          //  substract 1Gig from total swap on this node to accommodate OS needs for swapping. The
          //  getSwapTotal() returns swap space in KBs so normalize 1Gig
          long adjustedTotalSwapAvailable =
              agent.getNodeInfo().getNodeMetrics().getNodeMemory().getSwapTotal() - 1048576;
          // calculate the portion (in bytes) of swap this process is entitled to
          long maxProcessSwapUsage =
               (long) (adjustedTotalSwapAvailable*percentOfTotal)*1024;
           // assigned how much swap this process is entitled to. If it exceeds this number the Agent
           // will kill the process.
           ((ManagedProcess) managedProcess).setMaxSwapThreshold(maxProcessSwapUsage);
              logger.info(methodName, null, "---Process DuccId:"+duccProcess.getDuccId()+
                    " CGroup.getMaxMemoryLimit():"+((duccProcess.getCGroup().getMaxMemoryLimit()/1024)/1024)+" MBs"+
                    " Node Memory Total:"+(agent.getNodeInfo().getNodeMetrics().getNodeMemory().getMemTotal()/1024)+" MBs"+
                    " Percentage Of Real Memory:"+percentOfTotal+
                    " Adjusted Total Swap Available On Node:"+adjustedTotalSwapAvailable/1024+" MBs"+
                    " Process Entitled To Max:"+(maxProcessSwapUsage/1024)/1024+" MBs of Swap"
                    );

              //logger.info(methodName, null, "The Process With ID:"+duccProcess.getDuccId()+" is Entitled to the Max "+( (maxProcessSwapUsage/1024)/1024)+" Megs of Swap Space");
          // if configured to use cgroups and the process is the cgroup owner, create a cgroup
          // using Process DuccId as a name. Additional processes may be injected into the
          // cgroup by declaring cgroup owner id.
          if ( agent.useCgroups ) {
            //  JDs are of type Pop (Plain Old Process). JDs run in a reservation. The cgroup container
            //  is created for the reservation and we co-locate as many JDs as we can fit in it.
            //String containerId = ((ManagedProcess) managedProcess).getWorkDuccId()+"."+duccProcess.getCGroup().getId().getFriendly();
            String containerId = getContainerId();
            logger.info(methodName, null, "Creating CGroup with ID:"+containerId);         
            if ( !agent.cgroupsManager.cgroupExists(agent.cgroupsManager.getDuccCGroupBaseDir()+"/"+containerId) ) {
              boolean failed = false;
              // create cgroup container for JDs
              try {
                if ( createCGroupContainer(duccProcess, containerId, ((ManagedProcess)super.managedProcess).getOwner()) ) {
                  logger.info(methodName, null, "Created CGroup with ID:"+containerId+" With Memory Limit="+((ManagedProcess)super.managedProcess).getDuccProcess().getCGroup().getMaxMemoryLimit()+" Bytes");
                } else {
                  logger.info(methodName, null, "Failed To Create CGroup with ID:"+containerId);
                  duccProcess.setProcessState(ProcessState.Failed);
                  duccProcess.setReasonForStoppingProcess("CGroupCreationFailed");
                  failed = true;
                  agent.stop();
                }
              } catch( Exception e) {
                logger.error(methodName, null, e);
                failed = true;
                agent.stop();
              }
              if ( failed ) {
                throw new RuntimeException("The Agent is Unable To Create A CGroup with Container ID: "+containerId+". Rejecting Deployment of Process with ID:"+duccProcess.getDuccId());
              }
            } else {
              logger.info(methodName, null, "CGroup Exists with ID:"+containerId);         

            }
View Full Code Here

    logger.trace(methodName, null, messages.fetch("enter"));
    IDuccProcessMap processMap = duccWorkJob.getDriver().getProcessMap();
    Iterator<DuccId> processMapIterator = processMap.keySet().iterator();
    while(processMapIterator.hasNext()) {
      DuccId duccId = processMapIterator.next();
      IDuccProcess process = processMap.get(duccId);
      if(process.isActive()) {
        logger.debug(methodName, duccId,  messages.fetch("processes active"));
        status = false;
      }
    }
    logger.trace(methodName, null, messages.fetch("exit"));
View Full Code Here

    logger.trace(methodName, null, messages.fetch("enter"));
    IDuccProcessMap processMap = duccWorkJob.getProcessMap();
    Iterator<DuccId> processMapIterator = processMap.keySet().iterator();
    while(processMapIterator.hasNext()) {
      DuccId duccId = processMapIterator.next();
      IDuccProcess process = processMap.get(duccId);
      if(process.isActive()) {
        logger.debug(methodName, duccId,  messages.fetch("processes active"));
        status = false;
      }
    }
    logger.trace(methodName, null, messages.fetch("exit"));
View Full Code Here

      IDuccProcessMap processMap = driver.getProcessMap();
      if(processMap != null) {
        Collection<IDuccProcess> processCollection = processMap.values();
        Iterator<IDuccProcess> iterator = processCollection.iterator();
        while(iterator.hasNext()) {
          IDuccProcess process = iterator.next();
          process.setProcessJmxUrl(jdJmxUrl);
         
        }
      }
    }
  }
View Full Code Here

      IDuccProcessMap processMap = job.getProcessMap();
      DuccProcessWorkItemsMap pwiMap = jdStatusReport.getDuccProcessWorkItemsMap();
      Iterator<DuccId> iterator = pwiMap.keySet().iterator();
      while(iterator.hasNext()) {
        DuccId processId = iterator.next();
        IDuccProcess process = processMap.get(processId);
        IDuccProcessWorkItems pwi = pwiMap.get(processId);
        process.setProcessWorkItems(pwi);
        logger.trace(methodName, job.getDuccId(), "done:"+pwi.getCountDone()+" "+"error:"+pwi.getCountError()+" "+"dispatch:"+pwi.getCountDispatch()+" "+"unassigned:"+pwi.getCountUnassigned()+" "+"lost:"+pwi.getCountLost());
      }
    }
    catch(Throwable t) {
      logger.error(methodName, job.getDuccId(), t);
View Full Code Here

      IDuccProcessMap processMap = driver.getProcessMap();
      if(processMap != null) {
        Iterator<DuccId> iterator = processMap.keySet().iterator();
        while(iterator.hasNext()) {
          DuccId processId = iterator.next();
          IDuccProcess process = processMap.get(processId);
          process.setProcessWorkItems(pwi);
          logger.debug(methodName, job.getDuccId(), "done:"+pwi.getCountDone()+" "+"error:"+pwi.getCountError()+" "+"dispatch:"+pwi.getCountDispatch()+" "+"unassigned:"+pwi.getCountUnassigned()+" "+"lost:"+pwi.getCountLost());
        }
      }
    }
    catch(Throwable t) {
View Full Code Here

      IDuccProcessMap processMap = job.getProcessMap();
      Iterator<DuccId> iterator = processMap.keySet().iterator();
      boolean excessCapacity = isExcessCapacity(job, jdStatusReport);
      while(iterator.hasNext() && excessCapacity) {
        DuccId duccId = iterator.next();
        IDuccProcess process = processMap.get(duccId);
        if(!process.isDeallocated()) {
          String nodeIP = process.getNodeIdentity().getIp();
          String PID = process.getPID();
          if(!jdStatusReport.isOperating(nodeIP, PID)) {
            process.setResourceState(ResourceState.Deallocated);
            process.setProcessDeallocationType(ProcessDeallocationType.Voluntary);
            logger.info(methodName, job.getDuccId(), process.getDuccId(), "deallocated");
            retVal = true;
            excessCapacity = isExcessCapacity(job, jdStatusReport);
          }
        }
      }
View Full Code Here

TOP

Related Classes of org.apache.uima.ducc.transport.event.common.IDuccProcess

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.