org.apache.zookeeper.server.Request Java Examples

The following examples show how to use org.apache.zookeeper.server.Request. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: FinalRequestProcessorAspect.java    From pulsar with Apache License 2.0 5 votes vote down vote up
@Around("processRequest()")
public void timedProcessRequest(ProceedingJoinPoint joinPoint) throws Throwable {
    joinPoint.proceed();

    Request request = (Request) joinPoint.getArgs()[0];

    String type = requestTypeMap.getOrDefault(request.type, "unknown");
    requests.labels(type).inc();

    long latencyMs = Time.currentElapsedTime() - request.createTime;
    String latencyLabel = isWriteRequest(request.type) ? "write" : "read";
    requestsLatency.labels(latencyLabel).observe(latencyMs);
}
 
Example #2
Source File: ChaosMonkeyCnxnFactory.java    From xian with Apache License 2.0 4 votes vote down vote up
@Override
public void submitRequest(Request si)
{
    long remaining = firstError != 0 ? LOCKOUT_DURATION_MS - (System.currentTimeMillis() - firstError) : 0;
    if ( si.type != ZooDefs.OpCode.createSession && si.type != ZooDefs.OpCode.sync && si.type != ZooDefs.OpCode.ping
        && firstError != 0 && remaining > 0 )
    {
        log.debug("Rejected : " + si.toString());
        // Still reject request
        log.debug("Still not ready for " + remaining + "ms");
        ((NIOServerCnxn)si.cnxn).close();
        return;
    }
    // Submit the request to the legacy Zookeeper server
    log.debug("Applied : " + si.toString());
    super.submitRequest(si);
    // Raise an error if a lock is created
    if ( si.type == ZooDefs.OpCode.create )
    {
        CreateRequest createRequest = new CreateRequest();
        try
        {
            ByteBuffer duplicate = si.request.duplicate();
            duplicate.rewind();
            ByteBufferInputStream.byteBuffer2Record(duplicate, createRequest);
            if ( createRequest.getPath().startsWith(CHAOS_ZNODE_PREFIX)
                && firstError == 0 )
            {
                firstError = System.currentTimeMillis();
                // The znode has been created, close the connection and don't tell it to client
                log.warn("Closing connection right after " + createRequest.getPath() + " creation");
                ((NIOServerCnxn)si.cnxn).close();
            }
        }
        catch ( Exception e )
        {
            // Should not happen
            ((NIOServerCnxn)si.cnxn).close();
        }
    }
}
 
Example #3
Source File: TestConfigSetsAPIZkFailure.java    From lucene-solr with Apache License 2.0 4 votes vote down vote up
@Override
public void addCommittedProposal(Request request) {
  zkdb.addCommittedProposal(request);
}
 
Example #4
Source File: TestConfigSetsAPIZkFailure.java    From lucene-solr with Apache License 2.0 4 votes vote down vote up
@Override
public boolean append(Request si) throws IOException {
  return zkdb.append(si);
}
 
Example #5
Source File: ChaosMonkeyCnxnFactory.java    From curator with Apache License 2.0 4 votes vote down vote up
@Override
public void submitRequest(Request si)
{
    long remaining = firstError != 0 ? LOCKOUT_DURATION_MS - (System.currentTimeMillis() - firstError) : 0;
    if ( si.type != ZooDefs.OpCode.createSession && si.type != ZooDefs.OpCode.sync && si.type != ZooDefs.OpCode.ping
        && firstError != 0 && remaining > 0 )
    {
        log.debug("Rejected : " + si.toString());
        // Still reject request
        log.debug("Still not ready for " + remaining + "ms");
        Compatibility.serverCnxnClose(si.cnxn);
        return;
    }
    // Submit the request to the legacy Zookeeper server
    log.debug("Applied : " + si.toString());
    super.submitRequest(si);
    // Raise an error if a lock is created
    if ( (si.type == ZooDefs.OpCode.create) || (si.type == ZooDefs.OpCode.create2) )
    {
        CreateRequest createRequest = new CreateRequest();
        try
        {
            ByteBuffer duplicate = si.request.duplicate();
            duplicate.rewind();
            ByteBufferInputStream.byteBuffer2Record(duplicate, createRequest);
            if ( createRequest.getPath().startsWith(CHAOS_ZNODE_PREFIX)
                && firstError == 0 )
            {
                firstError = System.currentTimeMillis();
                // The znode has been created, close the connection and don't tell it to client
                log.warn("Closing connection right after " + createRequest.getPath() + " creation");
                Compatibility.serverCnxnClose(si.cnxn);
            }
        }
        catch ( Exception e )
        {
            // Should not happen
            Compatibility.serverCnxnClose(si.cnxn);
        }
    }
}