Grabs this copier for use by a Drools consequence.

@param workingMemory the consequence's {@link WorkingMemory}. Cannot
be <code>null</code>.
175725
void grab(KnowledgeHelper kh) {
        assert kh != null : "kh cannot be null";
        assert this.kh == null : "The previous user of this copier forgot to call release!";
        if (this.kh != null) {
            LOGGER.log(Level.WARNING, 
                    "The previous user of this copier forgot to call release. This causes a memory leak!");
        }
        this.kh = kh;
        this.uniqueIdProvider = 
                new ProviderBasedUniqueIdFactory(new JBossRulesDerivedLocalUniqueIdValuesProvider(this.kh.getWorkingMemory(), 
                        this.propId));
    }
893427
private synchronized Producer<EncodedImage> getBackgroundLocalFileFetchToEncodeMemorySequence() {
    if (FrescoSystrace.isTracing()) {
      FrescoSystrace.beginSection(
          "ProducerSequenceFactory#getBackgroundLocalFileFetchToEncodeMemorySequence");
    }
    if (mBackgroundLocalFileFetchToEncodedMemorySequence == null) {
      if (FrescoSystrace.isTracing()) {
        FrescoSystrace.beginSection(
            "ProducerSequenceFactory#getBackgroundLocalFileFetchToEncodeMemorySequence:init");
      }
      final LocalFileFetchProducer localFileFetchProducer =
          mProducerFactory.newLocalFileFetchProducer();

      final Producer<EncodedImage> toEncodedMultiplexProducer =
          newEncodedCacheMultiplexToTranscodeSequence(localFileFetchProducer);

      mBackgroundLocalFileFetchToEncodedMemorySequence =
          mProducerFactory.newBackgroundThreadHandoffProducer(
              toEncodedMultiplexProducer, mThreadHandoffProducerQueue);
      if (FrescoSystrace.isTracing()) {
        FrescoSystrace.endSection();
      }
    }
    if (FrescoSystrace.isTracing()) {
      FrescoSystrace.endSection();
    }
    return mBackgroundLocalFileFetchToEncodedMemorySequence;
  }
880567
private void validateClusterNameOfWorkItem( long woitRefNum ){
        WorkItem woit = workItemDao.findByRefNum( woitRefNum );
        validateClusterNameOfWorkflowInstance( woit.getWoinRefNum() );
    }
333139
public long getFreeMemory() {
    try {
      return (long) mBeanServer.getAttribute(new ObjectName("java.lang", "type", "OperatingSystem"), "FreePhysicalMemorySize");
    } catch (Exception e) {
      if (LOGGER.isDebugEnabled()) {
        LOGGER.debug("An exception occurred during memory check", e);
      }
    }
    return -1;
  }
61212
public void accumulate(Object workingMemoryContext,
                           Object context,
                           Tuple tuple,
                           InternalFactHandle handle,
                           Declaration[] declarations,
                           Declaration[] innerDeclarations,
                           WorkingMemory workingMemory) throws Exception {
        Object[]  localVars = ((MVELAccumulatorContext) context).getVariables();
        MVELAccumulatorFactoryContext factoryContext = (MVELAccumulatorFactoryContext)workingMemoryContext;
        VariableResolverFactory factory = factoryContext.getActionFactory();
        actionUnit.updateFactory( handle, tuple, localVars, (InternalWorkingMemory) workingMemory, workingMemory.getGlobalResolver(), factory );

        DroolsVarFactory df = ( DroolsVarFactory ) factory.getNextFactory();
        
        if ( reverse != null ) {
            Object[] shadow = new Object [df.getOtherVarsPos()];
            for ( int i = 0; i < df.getOtherVarsPos(); i++ ) {
                shadow[i] = factory.getIndexedVariableResolver( i ).getValue();
                
                
            }
            // SNAPSHOT variable values
            ((MVELAccumulatorContext) context).getShadow().put( handle.getId(), shadow);
        }
        MVELSafeHelper.getEvaluator().executeExpression( this.action,
                                null,
                                factory );
        
        
        if ( localVars.length > 0 ) {
            for ( int i = 0; i < df.getOtherVarsLength(); i++ ) {
                localVars[i] = factory.getIndexedVariableResolver( df.getOtherVarsPos() + i ).getValue();
            }
        }
        
        ((MVELAccumulatorContext) context).setVariables( localVars );        
    }
304078
private BlockingExecutor getExecutor(Work work)
   {
      BlockingExecutor executor = shortRunningExecutor;
      if (longRunningExecutor != null && WorkManagerUtil.isLongRunning(work))
      {
         executor = longRunningExecutor;
      }

      fireHintsComplete(work);

      return executor;
   }
238951
@Override public RecordWriter<K,SAMRecordWritable> getRecordWriter(
            TaskAttemptContext ctx)
            throws IOException
    {
        return getRecordWriter(ctx, getDefaultWorkFile(ctx, ""));
    }
1116441
public UserManagedCacheBuilder<K, V, T> withValueSerializingCopier() {
    UserManagedCacheBuilder<K, V, T> otherBuilder = new UserManagedCacheBuilder<>(this);
    otherBuilder.valueCopier = null;
    otherBuilder.useValueSerializingCopier = true;
    return otherBuilder;
  }
678985
public UserManagedCacheBuilder<K, V, T> withKeyCopier(Copier<K> keyCopier) {
    if (keyCopier == null) {
      throw new NullPointerException("Null key copier");
    }
    UserManagedCacheBuilder<K, V, T> otherBuilder = new UserManagedCacheBuilder<>(this);
    otherBuilder.keyCopier = keyCopier;
    otherBuilder.useKeySerializingCopier = false;
    return otherBuilder;
  }
241454
protected void storeWorkManager(WorkManager wm, XMLStreamWriter writer) throws Exception
   {
      WorkManagerSecurity s = wm.getSecurity();

      writer.writeStartElement(CommonXML.ELEMENT_WORKMANAGER);
      writer.writeStartElement(CommonXML.ELEMENT_WORKMANAGER_SECURITY);

      writer.writeStartElement(CommonXML.ELEMENT_MAPPING_REQUIRED);
      writer.writeCharacters(s.getValue(CommonXML.ELEMENT_MAPPING_REQUIRED, Boolean.toString(s.isMappingRequired())));
      writer.writeEndElement();

      writer.writeStartElement(CommonXML.ELEMENT_DOMAIN);
      writer.writeCharacters(s.getValue(CommonXML.ELEMENT_DOMAIN, s.getDomain()));
      writer.writeEndElement();

      if (s.getDefaultPrincipal() != null)
      {
         writer.writeStartElement(CommonXML.ELEMENT_DEFAULT_PRINCIPAL);
         writer.writeCharacters(s.getValue(CommonXML.ELEMENT_DEFAULT_PRINCIPAL, s.getDefaultPrincipal()));
         writer.writeEndElement();
      }

      if (s.getDefaultGroups() != null && !s.getDefaultGroups().isEmpty())
      {
         writer.writeStartElement(CommonXML.ELEMENT_DEFAULT_GROUPS);
         for (int i = 0; i < s.getDefaultGroups().size(); i++)
         {
            writer.writeStartElement(CommonXML.ELEMENT_GROUP);
            writer.writeCharacters(s.getValue(CommonXML.ELEMENT_DEFAULT_GROUPS, Integer.toString(i),
                                              s.getDefaultGroups().get(i)));
            writer.writeEndElement();
         }
         writer.writeEndElement();
      }

      if ((s.getUserMappings() != null && !s.getUserMappings().isEmpty()) ||
          (s.getGroupMappings() != null && !s.getGroupMappings().isEmpty()))
      {
         writer.writeStartElement(CommonXML.ELEMENT_MAPPINGS);

         if (s.getUserMappings() != null && !s.getUserMappings().isEmpty())
         {
            writer.writeStartElement(CommonXML.ELEMENT_USERS);
            
            for (Map.Entry<String, String> entry : s.getUserMappings().entrySet())
            {
               writer.writeStartElement(CommonXML.ELEMENT_MAP);
               writer.writeAttribute(CommonXML.ATTRIBUTE_FROM,
                                     s.getValue(CommonXML.ELEMENT_USERS, entry.getKey(), entry.getKey()));
               writer.writeAttribute(CommonXML.ATTRIBUTE_TO,
                                     s.getValue(CommonXML.ELEMENT_USERS, entry.getValue(), entry.getValue()));
               writer.writeEndElement();
            }

            writer.writeEndElement();
         }

         if (s.getGroupMappings() != null && !s.getGroupMappings().isEmpty())
         {
            writer.writeStartElement(CommonXML.ELEMENT_GROUPS);
            
            for (Map.Entry<String, String> entry : s.getGroupMappings().entrySet())
            {
               writer.writeStartElement(CommonXML.ELEMENT_MAP);
               writer.writeAttribute(CommonXML.ATTRIBUTE_FROM,
                                     s.getValue(CommonXML.ELEMENT_GROUPS, entry.getKey(), entry.getKey()));
               writer.writeAttribute(CommonXML.ATTRIBUTE_TO,
                                     s.getValue(CommonXML.ELEMENT_GROUPS, entry.getValue(), entry.getValue()));
               writer.writeEndElement();
            }

            writer.writeEndElement();
         }

         writer.writeEndElement();
      }

      writer.writeEndElement();
      writer.writeEndElement();
   }
417323
public void unregisterWorkManager(WorkManager wm)
   {
      if (wm != null)
      {
         if (wm.getName() == null || wm.getName().trim().equals(""))
            throw new IllegalArgumentException("The name of WorkManager is invalid: " + wm);

         if (trace)
            log.tracef("Unregistering WorkManager: %s", wm);

         if (workmanagers.keySet().contains(wm.getName()))
         {
            workmanagers.remove(wm.getName());

            // Clear any events
            if (wm instanceof DistributedWorkManager)
            {
               WorkManagerEventQueue wmeq = WorkManagerEventQueue.getInstance();
               List<WorkManagerEvent> events = wmeq.getEvents(wm.getName());
               events.clear();
            }
         }
      }
   }
743732
protected final @Nullable V copyValue(@Nullable Expirable<V> expirable) {
    if (expirable == null) {
      return null;
    }
    V copy = copier.copy(expirable.get(), cacheManager.getClassLoader());
    return requireNonNull(copy);
  }
480270
private Memory createNodeMemory( MemoryFactory node,
                                     InternalWorkingMemory wm ) {
        try {
            this.lock.lock();
            // need to try again in a synchronized code block to make sure
            // it was not created yet
            Memory memory = this.memories.get( node.getMemoryId() );
            if( memory == null ) {
                memory = node.createMemory( this.kBase.getConfiguration(), wm );

                if( !this.memories.compareAndSet( node.getMemoryId(), null, memory ) ) {
                    memory = this.memories.get( node.getMemoryId() );
                }

            }
            return memory;
        } finally {
            this.lock.unlock();

        }
    }
593683
public long executeStartWork(org.ironjacamar.core.spi.workmanager.Address logicalAddress,
                                ClassBundle classBundle, byte[] b)
      throws WorkException
   {
      ByteArrayInputStream bias = new ByteArrayInputStream(b);
      WorkObjectInputStream wois = null;
      try
      {
         WorkClassLoader wcl = SecurityActions.createWorkClassLoader(classBundle);
         
         wois = new WorkObjectInputStream(bias, wcl);

         DistributableWork dw = (DistributableWork)wois.readObject();

         return localStartWork(logicalAddress, dw);
      }
      catch (WorkException we)
      {
         throw we;
      }
      catch (Throwable t)
      {
         throw new WorkException("Error during doWork: " + t.getMessage(), t);
      }
      finally
      {
         if (wois != null)
         {
            try
            {
               wois.close();
            }
            catch (IOException ioe)
            {
               // Ignore
            }
         }
      }
   }
824740
public void propagateActions( InternalWorkingMemory workingMemory ) {
        final PropagationQueueingNodeMemory memory = workingMemory.getNodeMemory( this );

        // first we clear up the action queued flag
        memory.isQueued().compareAndSet( true,
                                         false );

        // we limit the propagation to avoid a hang when this queue is never empty
        Action next;
        for ( int counter = 0; counter < PROPAGATION_SLICE_LIMIT; counter++ ) {
            next = memory.getNextAction();
            if ( next != null ) {
                next.execute( this.sink,
                        workingMemory );
            } else {
                break;
            }
        }

        if ( memory.hasNextAction() && memory.isQueued().compareAndSet( false,
                                                                        true ) ) {
            // add action to the queue again.
            workingMemory.queueWorkingMemoryAction( this.action );
        }
    }
761917
static Object workObject(Map<String, Object> workList, String name, boolean isArray) {
        logger.trace("get working object for {}", name);

        if (workList.get(name) != null) return workList.get(name);
        else {
            String[] parts = splitName(name);   // parts: (parent, name, isArray)
            Map<String, Object> parentObj = (Map<String, Object>) workObject(workList, parts[0], false);
            Object theObj = isArray ? new ArrayList<String>() : new HashMap<String, Object>();

            parentObj.put(parts[1], theObj);
            workList.put(name, theObj);

            return theObj;
        }
    }
88223
public long getTaskCount() {
        final ReentrantLock mainLock = this.mainLock;
        mainLock.lock();
        try {
            long n = completedTaskCount;
            for (Worker w : workers) {
                n += w.completedTasks;
                if (w.isLocked())
                    ++n;
            }
            return n + workQueue.size();
        } finally {
            mainLock.unlock();
        }
    }