Search in sources :

Example 6 with Request

use of org.apache.zookeeper.server.Request in project zookeeper by apache.

the class QuorumZooKeeperServer method upgrade.

/**
 * Implements the SessionUpgrader interface,
 *
 * @param sessionId
 */
public void upgrade(long sessionId) {
    Request request = makeUpgradeRequest(sessionId);
    if (request != null) {
        LOG.info("Upgrading session 0x{}", Long.toHexString(sessionId));
        // This must be a global request
        submitRequest(request);
    }
}
Also used : CreateRequest(org.apache.zookeeper.proto.CreateRequest) Request(org.apache.zookeeper.server.Request)

Example 7 with Request

use of org.apache.zookeeper.server.Request in project zookeeper by apache.

the class ObserverRequestProcessor method processRequest.

/**
 * Simply queue the request, which will be processed in FIFO order.
 */
public void processRequest(Request request) {
    if (!finished) {
        Request upgradeRequest = null;
        try {
            upgradeRequest = zks.checkUpgradeSession(request);
        } catch (KeeperException ke) {
            if (request.getHdr() != null) {
                request.getHdr().setType(OpCode.error);
                request.setTxn(new ErrorTxn(ke.code().intValue()));
            }
            request.setException(ke);
            LOG.info("Error creating upgrade request", ke);
        } catch (IOException ie) {
            LOG.error("Unexpected error in upgrade", ie);
        }
        if (upgradeRequest != null) {
            queuedRequests.add(upgradeRequest);
        }
        queuedRequests.add(request);
    }
}
Also used : ErrorTxn(org.apache.zookeeper.txn.ErrorTxn) Request(org.apache.zookeeper.server.Request) IOException(java.io.IOException) KeeperException(org.apache.zookeeper.KeeperException)

Example 8 with Request

use of org.apache.zookeeper.server.Request in project zookeeper by apache.

the class Slf4JAuditLoggerTest method getUser.

private String getUser() {
    ServerCnxn next = getServerCnxn();
    Request request = new Request(next, -1, -1, -1, null, next.getAuthInfo());
    return request.getUsersForAudit();
}
Also used : ServerCnxn(org.apache.zookeeper.server.ServerCnxn) Request(org.apache.zookeeper.server.Request)

Example 9 with Request

use of org.apache.zookeeper.server.Request in project zookeeper by apache.

the class TruncateTest method append.

private void append(ZKDatabase zkdb, int i) throws IOException {
    TxnHeader hdr = new TxnHeader(1, 1, i, 1, ZooDefs.OpCode.setData);
    Record txn = new SetDataTxn("/foo" + i, new byte[0], 1);
    Request req = new Request(0, 0, 0, hdr, txn, 0);
    zkdb.append(req);
    zkdb.commit();
}
Also used : Request(org.apache.zookeeper.server.Request) Record(org.apache.jute.Record) SetDataTxn(org.apache.zookeeper.txn.SetDataTxn) TxnHeader(org.apache.zookeeper.txn.TxnHeader)

Example 10 with Request

use of org.apache.zookeeper.server.Request in project zookeeper by apache.

the class LeaderBeanTest method testGetProposalSize.

@Test
public void testGetProposalSize() throws IOException, Leader.XidRolloverException {
    // Arrange
    Request req = createMockRequest();
    // Act
    leader.propose(req);
    // Assert
    byte[] data = SerializeUtils.serializeRequest(req);
    assertEquals(data.length, leaderBean.getLastProposalSize());
    assertEquals(data.length, leaderBean.getMinProposalSize());
    assertEquals(data.length, leaderBean.getMaxProposalSize());
}
Also used : Request(org.apache.zookeeper.server.Request) Test(org.junit.jupiter.api.Test)

Aggregations

Request (org.apache.zookeeper.server.Request)51 Test (org.junit.jupiter.api.Test)25 CreateRequest (org.apache.zookeeper.proto.CreateRequest)15 IOException (java.io.IOException)9 ByteBuffer (java.nio.ByteBuffer)9 GetDataRequest (org.apache.zookeeper.proto.GetDataRequest)9 SetDataRequest (org.apache.zookeeper.proto.SetDataRequest)9 TxnHeader (org.apache.zookeeper.txn.TxnHeader)9 HashSet (java.util.HashSet)8 ByteArrayOutputStream (java.io.ByteArrayOutputStream)6 BinaryOutputArchive (org.apache.jute.BinaryOutputArchive)6 Record (org.apache.jute.Record)6 KeeperException (org.apache.zookeeper.KeeperException)5 SetDataTxn (org.apache.zookeeper.txn.SetDataTxn)5 Id (org.apache.zookeeper.data.Id)4 ErrorTxn (org.apache.zookeeper.txn.ErrorTxn)4 OutputArchive (org.apache.jute.OutputArchive)3 ZooKeeper (org.apache.zookeeper.ZooKeeper)3 TxnLogEntry (org.apache.zookeeper.server.TxnLogEntry)3 QuorumVerifier (org.apache.zookeeper.server.quorum.flexible.QuorumVerifier)3