/*
public void onNonce(String algorithm, String nonce)
{
OutHamp out = (OutHamp) getConnection();

out.onNonce(algorithm, nonce);
}
428870
@Override
  protected ServiceRefAmp lookupService(String address)
  {
    String prefix = "cluster://";

    if (address.startsWith(prefix)) {
      int p = address.indexOf('/', prefix.length() + 1);
      
      if (p > 0) {
        String cluster = address.substring(prefix.length(), p);
        String path = address.substring(p);
    
        return lookupService(cluster, path);
      }
    }
    
    ServiceRefAmp serviceRef = services().service(address);
    
    return serviceRef;
  }
59699
public void startEnvelope(String method)
        throws IOException
    {
        int offset = _offset;

        if (SIZE < offset + 32) {
            flushBuffer();
            offset = _offset;
        }

        _buffer[_offset++] = (byte) 'E';

        writeString(method);
    }
1177927
function onStateChange(e)
    {
        if(scope._conn)
        {
            if(scope._conn.iceConnectionState == "connected")
            {
                if(scope.onConnected)
                {
                    scope.onConnected(scope);
                }
            }
            if(scope._conn.iceConnectionState == "failed" || scope._conn.iceConnectionState == "disconnected")
            {
                if(scope.onConnectionFail)
                {
                    scope.onConnectionFail(scope);
                }
                if(scope.type == "offer")
                {
                    scope.createOffer();
                }
            }
            if(scope._conn.iceConnectionState == "closed")
            {
                if(scope.onClosed)
                {
                    scope.onClosed(scope);
                }
                scope.dispose();
            }
        }
    }
336975
@Override
  public void onSessionStarted(Session session) {
    session.setUseBlockingRead(true);
    session.setAttribute(HEART_BEAT_FAIL_COUNT_ATTR, new AtomicInteger(0));
    for (MemcachedClientStateListener listener : this.client.getStateListeners()) {
      listener.onConnected(this.client, session.getRemoteSocketAddress());
    }
    this.listener.onConnect((MemcachedTCPSession) session, this.client);
  }
832268
private static byte[] hmacTemplate(byte[] data, byte[] key, String algorithm) {
        if (data == null || data.length == 0 || key == null || key.length == 0) return null;
        try {
            SecretKeySpec secretKey = new SecretKeySpec(key, algorithm);
            Mac           mac       = Mac.getInstance(algorithm);
            mac.init(secretKey);
            return mac.doFinal(data);
        } catch (InvalidKeyException | NoSuchAlgorithmException e) {
            e.printStackTrace();
            return null;
        }
    }
913553
@Override
	public synchronized void enable(boolean on)
	{
		if (!on)
		{
			dump(true);
			cached = null;
		}

		enabled = on;
	}
49610
public void onSuccess(T result) {
        try {
            statusLock.lock();
            value = result;
            status = new RequestStatus(RequestStatusCode.OK);
            statusLockChangedCondition.signalAll();
        } catch (Exception e) {
            status = new RequestStatus(RequestStatusCode.ERROR);
            exception = new JoynrRuntimeException(e);
        } finally {
            statusLock.unlock();
        }
    }
875270
@Override
    public Collection<FixityResult> checkFixity(final String algorithm) {

        try (FixityInputStream fixityInputStream = new FixityInputStream(
                this.getInputStream(), MessageDigest.getInstance(algorithm))) {

            // actually calculate the digest by consuming the stream
            while (fixityInputStream.read(devNull) != -1) { }

            final URI calculatedChecksum =
                    ContentDigest.asURI(algorithm, fixityInputStream.getMessageDigest().digest());

            final FixityResult result =
                new FixityResultImpl(getExternalIdentifier(),
                                    fixityInputStream.getByteCount(),
                                    calculatedChecksum,
                                    algorithm);

            return singletonList(result);
        } catch (final IOException e) {
            LOGGER.debug("Got error closing input stream: {}", e);
            throw new RepositoryRuntimeException(e);
        } catch (final NoSuchAlgorithmException e1) {
            throw new RepositoryRuntimeException(e1);
        }
    }
979844
@Override
	public void onCreate(int id) {
		this.processorId = id;
		this.statistics= new double[]{0.0,0,0};	
		this.ruleNumberID=0;
		this.defaultRule = newRule(++this.ruleNumberID);
		
		this.ruleSet = new LinkedList<ActiveRule>();
	}
399373
public void addNewInstanceMethod(Method method) {
        final CachedMethod cachedMethod = CachedMethod.find(method);
        NewInstanceMetaMethod newMethod = new NewInstanceMetaMethod(cachedMethod);
        final CachedClass declaringClass = newMethod.getDeclaringClass();
        addNewInstanceMethodToIndex(newMethod, metaMethodIndex.getHeader(declaringClass.getTheClass()));
    }
283345
public void onText (@Nonnull final char [] aText, @Nonnegative final int nOfs, @Nonnegative final int nLen)
  {
    onText (aText, nOfs, nLen, true);
  }
1134905
@Override
    protected void onMethodEntry() {
        if (enabledListeners.isEmpty())
            return;

        String probeKey = createKey();
        ProbeImpl probe = getProbe(probeKey);
        long probeId = probe.getIdentifier();

        setProbeInProgress(true);
        visitLdcInsn(Long.valueOf(probeId)); // long1 long2
        if (isStatic() || isConstructor()) {
            visitInsn(ACONST_NULL); // long1 long2 this
        } else {
            visitVarInsn(ALOAD, 0); // long1 long2 this
        }
        visitInsn(ACONST_NULL); // long1 long2 this that
        createParameterArray(); // long1 long2 this that args
        visitFireProbeInvocation();
        setProbeInProgress(false);

        setProbeListeners(probe, enabledListeners);
    }
1368395
public void onReceive(Object object) {
		if (!closed && object != null) {
			synchronized (queue) {
				queue.addLast(object);
				if (limit > 0 && queue.size() > limit && !queue.isEmpty()) {
					queue.removeFirst();
				}
			}
		}
	}
641910
@Override
	public void onRecv(byte[] b, int off, int len) {
		connection.onRecv(b, off, len);
	}
963486
private void finishConnect(final SelectionKey sk, final MemcachedNode node)
    throws IOException {
    if (verifyAliveOnConnect) {
      final CountDownLatch latch = new CountDownLatch(1);
      final OperationFuture<Boolean> rv = new OperationFuture<Boolean>("noop",
        latch, 2500, listenerExecutorService);
      NoopOperation testOp = opFact.noop(new OperationCallback() {
        public void receivedStatus(OperationStatus status) {
          rv.set(status.isSuccess(), status);
        }

        @Override
        public void complete() {
          latch.countDown();
        }
      });

      testOp.setHandlingNode(node);
      testOp.initialize();
      checkState();
      insertOperation(node, testOp);
      node.copyInputQueue();

      boolean done = false;
      if (sk.isValid()) {
        long timeout = TimeUnit.MILLISECONDS.toNanos(
          connectionFactory.getOperationTimeout());

        long stop = System.nanoTime() + timeout;
        while (stop > System.nanoTime()) {
          handleWrites(node);
          handleReads(node);
          if(done = (latch.getCount() == 0)) {
            break;
          }
        }
      }

      if (!done || testOp.isCancelled() || testOp.hasErrored()
        || testOp.isTimedOut()) {
        throw new ConnectException("Could not send noop upon connect! "
          + "This may indicate a running, but not responding memcached "
          + "instance.");
      }
    }

    connected(node);
    addedQueue.offer(node);
    if (node.getWbuf().hasRemaining()) {
      handleWrites(node);
    }
  }
127014
@Override
    public void onRPCError(int handle, int code, String text) {
        if (handle == asyncHandle) {
            asyncHandle = 0;
            ZKUtil.fireEvent(new AsyncRPCErrorEvent(rpcName, target, code, text, handle));
            rpcName = null;
        }
    }
962174
@Override
    public void onBeforeExecutionEvent(BeforeExecutionEvent event) {
        LepManager manager = event.getSource();
        ScopedContext threadContext = manager.getContext(ContextScopes.THREAD);
        if (threadContext == null) {
            throw new IllegalStateException("LEP manager thread context doesn't initialized");
        }

        TenantContext tenantContext = getRequiredValue(threadContext, THREAD_CONTEXT_KEY_TENANT_CONTEXT,
                                                       TenantContext.class);
        XmAuthenticationContext authContext = getRequiredValue(threadContext, THREAD_CONTEXT_KEY_AUTH_CONTEXT,
                                                               XmAuthenticationContext.class);

        ScopedContext executionContext = manager.getContext(ContextScopes.EXECUTION);
        // add contexts
        executionContext.setValue(BINDING_KEY_TENANT_CONTEXT, tenantContext);
        executionContext.setValue(BINDING_KEY_AUTH_CONTEXT, authContext);

        bindExecutionContext(executionContext);
    }