类org.apache.zookeeper.server.Request源码实例Demo

下面列出了怎么用org.apache.zookeeper.server.Request的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: pulsar   文件: FinalRequestProcessorAspect.java
@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);
}
 
源代码2 项目: xian   文件: ChaosMonkeyCnxnFactory.java
@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();
        }
    }
}
 
源代码3 项目: lucene-solr   文件: TestConfigSetsAPIZkFailure.java
@Override
public void addCommittedProposal(Request request) {
  zkdb.addCommittedProposal(request);
}
 
源代码4 项目: lucene-solr   文件: TestConfigSetsAPIZkFailure.java
@Override
public boolean append(Request si) throws IOException {
  return zkdb.append(si);
}
 
源代码5 项目: curator   文件: ChaosMonkeyCnxnFactory.java
@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);
        }
    }
}
 
 类所在包
 类方法
 同包方法