当前位置: 首页>>代码示例>>Java>>正文


Java Record类代码示例

本文整理汇总了Java中org.apache.jute.Record的典型用法代码示例。如果您正苦于以下问题:Java Record类的具体用法?Java Record怎么用?Java Record使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Record类属于org.apache.jute包,在下文中一共展示了Record类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: sendPacket

import org.apache.jute.Record; //导入依赖的package包/类
public void sendPacket(Record request, Record response, AsyncCallback cb, int opCode)
throws IOException {
    // Generate Xid now because it will be sent immediately,
    // by call to sendThread.sendPacket() below.
    int xid = getXid();
    RequestHeader h = new RequestHeader();
    h.setXid(xid);
    h.setType(opCode);

    ReplyHeader r = new ReplyHeader();
    r.setXid(xid);

    Packet p = new Packet(h, r, request, response, null, false);
    p.cb = cb;
    sendThread.sendPacket(p);
}
 
开发者ID:maoling,项目名称:fuck_zookeeper,代码行数:17,代码来源:ClientCnxn.java

示例2: addRequestToSyncProcessor

import org.apache.jute.Record; //导入依赖的package包/类
private void addRequestToSyncProcessor() {
    long zxid = ZxidUtils.makeZxid(3, 7);
    TxnHeader hdr = new TxnHeader(1, 1, zxid, 1,
            ZooDefs.OpCode.setData);
    Record txn = new SetDataTxn("/foo" + zxid, new byte[0], 1);
    byte[] buf;
    try {
        buf = Util.marshallTxnEntry(hdr, txn);
    } catch (IOException e) {
        LOG.error("IOException while adding request to SyncRequestProcessor", e);
        Assert.fail("IOException while adding request to SyncRequestProcessor!");
        return;
    }
    NettyServerCnxnFactory factory = new NettyServerCnxnFactory();
    final MockNettyServerCnxn nettyCnxn = new MockNettyServerCnxn(null,
            this, factory);
    Request req = new Request(nettyCnxn, 1, 1, ZooDefs.OpCode.setData,
            ByteBuffer.wrap(buf), null);
    req.hdr = hdr;
    req.txn = txn;
    syncProcessor.processRequest(req);
}
 
开发者ID:maoling,项目名称:fuck_zookeeper,代码行数:23,代码来源:ZooKeeperServerMainTest.java

示例3: testPad

import org.apache.jute.Record; //导入依赖的package包/类
/**
 * Simulates ZOOKEEPER-1069 and verifies that flush() before padLogFile
 * fixes it.
 */
@Test
public void testPad() throws Exception {
    File tmpDir = ClientBase.createTmpDir();
    FileTxnLog txnLog = new FileTxnLog(tmpDir);
    TxnHeader txnHeader = new TxnHeader(0xabcd, 0x123, 0x123,
          System.currentTimeMillis(), OpCode.create);
    Record txn = new CreateTxn("/Test", new byte[0], null, false, 1);
    txnLog.append(txnHeader, txn);
    FileInputStream in = new FileInputStream(tmpDir.getPath() + "/log." +
          Long.toHexString(txnHeader.getZxid()));
    BinaryInputArchive ia  = BinaryInputArchive.getArchive(in);
    FileHeader header = new FileHeader();
    header.deserialize(ia, "fileheader");
    LOG.info("Received magic : " + header.getMagic() +
          " Expected : " + FileTxnLog.TXNLOG_MAGIC);
    Assert.assertTrue("Missing magic number ",
          header.getMagic() == FileTxnLog.TXNLOG_MAGIC);
}
 
开发者ID:maoling,项目名称:fuck_zookeeper,代码行数:23,代码来源:LoadFromLogTest.java

示例4: processTxn

import org.apache.jute.Record; //导入依赖的package包/类
public ProcessTxnResult processTxn(TxnHeader hdr, Record txn) {
    ProcessTxnResult rc;
    int opCode = hdr.getType();
    long sessionId = hdr.getClientId();
    rc = getZKDatabase().processTxn(hdr, txn);
    if (opCode == OpCode.createSession) {
        if (txn instanceof CreateSessionTxn) {
            CreateSessionTxn cst = (CreateSessionTxn) txn;
            sessionTracker.addSession(sessionId, cst
                    .getTimeOut());
        } else {
            LOG.warn("*****>>>>> Got "
                    + txn.getClass() + " "
                    + txn.toString());
        }
    } else if (opCode == OpCode.closeSession) {
        sessionTracker.removeSession(sessionId);
    }
    return rc;
}
 
开发者ID:l294265421,项目名称:ZooKeeper,代码行数:21,代码来源:ZooKeeperServer.java

示例5: create

import org.apache.jute.Record; //导入依赖的package包/类
/**
 * The asynchronous version of create with ttl.
 *
 * @see #create(String, byte[], List, CreateMode, Stat, long)
 */
public void create(final String path, byte data[], List<ACL> acl,
        CreateMode createMode, Create2Callback cb, Object ctx, long ttl)
{
    final String clientPath = path;
    PathUtils.validatePath(clientPath, createMode.isSequential());
    EphemeralType.validateTTL(createMode, ttl);

    final String serverPath = prependChroot(clientPath);

    RequestHeader h = new RequestHeader();
    setCreateHeader(createMode, h);
    ReplyHeader r = new ReplyHeader();
    Create2Response response = new Create2Response();
    Record record = makeCreateRecord(createMode, serverPath, data, acl, ttl);
    cnxn.queuePacket(h, r, record, response, cb, clientPath,
            serverPath, ctx, null);
}
 
开发者ID:didichuxing2,项目名称:https-github.com-apache-zookeeper,代码行数:23,代码来源:ZooKeeper.java

示例6: removeWatches

import org.apache.jute.Record; //导入依赖的package包/类
private void removeWatches(int opCode, String path, Watcher watcher,
        WatcherType watcherType, boolean local)
        throws InterruptedException, KeeperException {
    PathUtils.validatePath(path);
    final String clientPath = path;
    final String serverPath = prependChroot(clientPath);
    WatchDeregistration wcb = new WatchDeregistration(clientPath, watcher,
            watcherType, local, watchManager);

    RequestHeader h = new RequestHeader();
    h.setType(opCode);
    Record request = getRemoveWatchesRequest(opCode, watcherType,
            serverPath);

    ReplyHeader r = cnxn.submitRequest(h, request, null, null, wcb);
    if (r.getErr() != 0) {
        throw KeeperException.create(KeeperException.Code.get(r.getErr()),
                clientPath);
    }
}
 
开发者ID:didichuxing2,项目名称:https-github.com-apache-zookeeper,代码行数:21,代码来源:ZooKeeper.java

示例7: testPad

import org.apache.jute.Record; //导入依赖的package包/类
/**
 * Simulates ZOOKEEPER-1069 and verifies that flush() before padLogFile
 * fixes it.
 */
@Test
public void testPad() throws Exception {
    File tmpDir = ClientBase.createTmpDir();
    FileTxnLog txnLog = new FileTxnLog(tmpDir);
    TxnHeader txnHeader = new TxnHeader(0xabcd, 0x123, 0x123,
          Time.currentElapsedTime(), OpCode.create);
    Record txn = new CreateTxn("/Test", new byte[0], null, false, 1);
    txnLog.append(txnHeader, txn);
    FileInputStream in = new FileInputStream(tmpDir.getPath() + "/log." +
          Long.toHexString(txnHeader.getZxid()));
    BinaryInputArchive ia  = BinaryInputArchive.getArchive(in);
    FileHeader header = new FileHeader();
    header.deserialize(ia, "fileheader");
    LOG.info("Received magic : " + header.getMagic() +
          " Expected : " + FileTxnLog.TXNLOG_MAGIC);
    Assert.assertTrue("Missing magic number ",
          header.getMagic() == FileTxnLog.TXNLOG_MAGIC);
}
 
开发者ID:didichuxing2,项目名称:https-github.com-apache-zookeeper,代码行数:23,代码来源:LoadFromLogTest.java

示例8: processPacket

import org.apache.jute.Record; //导入依赖的package包/类
/**
 * Controls the response of an observer to the receipt of a quorumpacket
 * @param qp
 * @throws IOException
 */
protected void processPacket(QuorumPacket qp) throws IOException{
    switch (qp.getType()) {
    case Leader.PING:
        ping(qp);
        break;
    case Leader.PROPOSAL:
        LOG.warn("Ignoring proposal");
        break;
    case Leader.COMMIT:
        LOG.warn("Ignoring commit");            
        break;            
    case Leader.UPTODATE:
        LOG.error("Received an UPTODATE message after Observer started");
        break;
    case Leader.REVALIDATE:
        revalidate(qp);
        break;
    case Leader.SYNC:
        ((ObserverZooKeeperServer)zk).sync();
        break;
    case Leader.INFORM:            
        TxnHeader hdr = new TxnHeader();
        Record txn = SerializeUtils.deserializeTxn(qp.getData(), hdr);
        Request request = new Request (null, hdr.getClientId(), 
                                       hdr.getCxid(),
                                       hdr.getType(), null, null);
        request.txn = txn;
        request.hdr = hdr;
        ObserverZooKeeperServer obs = (ObserverZooKeeperServer)zk;
        obs.commitRequest(request);            
        break;
    }
}
 
开发者ID:maoling,项目名称:fuck_zookeeper,代码行数:39,代码来源:Observer.java

示例9: processPacket

import org.apache.jute.Record; //导入依赖的package包/类
/**
 * Examine the packet received in qp and dispatch based on its contents.
 * @param qp
 * @throws IOException
 */
protected void processPacket(QuorumPacket qp) throws IOException{
    switch (qp.getType()) {
    case Leader.PING:            
        ping(qp);            
        break;
    case Leader.PROPOSAL:            
        TxnHeader hdr = new TxnHeader();
        Record txn = SerializeUtils.deserializeTxn(qp.getData(), hdr);
        if (hdr.getZxid() != lastQueued + 1) {
            LOG.warn("Got zxid 0x"
                    + Long.toHexString(hdr.getZxid())
                    + " expected 0x"
                    + Long.toHexString(lastQueued + 1));
        }
        lastQueued = hdr.getZxid();
        fzk.logRequest(hdr, txn);
        break;
    case Leader.COMMIT:
        fzk.commit(qp.getZxid());
        break;
    case Leader.UPTODATE:
        LOG.error("Received an UPTODATE message after Follower started");
        break;
    case Leader.REVALIDATE:
        revalidate(qp);
        break;
    case Leader.SYNC:
        fzk.sync();
        break;
    }
}
 
开发者ID:maoling,项目名称:fuck_zookeeper,代码行数:37,代码来源:Follower.java

示例10: marshallTxnEntry

import org.apache.jute.Record; //导入依赖的package包/类
/**
 * Serializes transaction header and transaction data into a byte buffer.
 *  
 * @param hdr transaction header
 * @param txn transaction data
 * @return serialized transaction record
 * @throws IOException
 */
public static byte[] marshallTxnEntry(TxnHeader hdr, Record txn)
        throws IOException {
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    OutputArchive boa = BinaryOutputArchive.getArchive(baos);

    hdr.serialize(boa, "hdr");
    if (txn != null) {
        txn.serialize(boa, "txn");
    }
    return baos.toByteArray();
}
 
开发者ID:maoling,项目名称:fuck_zookeeper,代码行数:20,代码来源:Util.java

示例11: sendResponse

import org.apache.jute.Record; //导入依赖的package包/类
@Override
public void sendResponse(ReplyHeader h, Record r, String tag)
        throws IOException {
    if (!channel.isOpen()) {
        return;
    }
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    // Make space for length
    BinaryOutputArchive bos = BinaryOutputArchive.getArchive(baos);
    try {
        baos.write(fourBytes);
        bos.writeRecord(h, "header");
        if (r != null) {
            bos.writeRecord(r, tag);
        }
        baos.close();
    } catch (IOException e) {
        LOG.error("Error serializing response");
    }
    byte b[] = baos.toByteArray();
    ByteBuffer bb = ByteBuffer.wrap(b);
    bb.putInt(b.length - 4).rewind();
    sendBuffer(bb);
    if (h.getXid() > 0) {
        // zks cannot be null otherwise we would not have gotten here!
        if (!zkServer.shouldThrottle(outstandingCount.decrementAndGet())) {
            enableRecv();
        }
    }
}
 
开发者ID:maoling,项目名称:fuck_zookeeper,代码行数:31,代码来源:NettyServerCnxn.java

示例12: process

import org.apache.jute.Record; //导入依赖的package包/类
private void process(List<Op> ops) throws Exception {
    pLatch = new CountDownLatch(1);
    processor = new PrepRequestProcessor(zks, new MyRequestProcessor());

    Record record = new MultiTransactionRecord(ops);
    Request req = createRequest(record, OpCode.multi);

    processor.pRequest(req);
    Assert.assertTrue("request hasn't been processed in chain", pLatch.await(5, TimeUnit.SECONDS));
}
 
开发者ID:l294265421,项目名称:ZooKeeper,代码行数:11,代码来源:PrepRequestProcessorTest.java

示例13: createRequest

import org.apache.jute.Record; //导入依赖的package包/类
private Request createRequest(Record record, int opCode) throws IOException {
    // encoding
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    BinaryOutputArchive boa = BinaryOutputArchive.getArchive(baos);
    record.serialize(boa, "request");
    baos.close();

    // Id
    List<Id> ids = Arrays.asList(Ids.ANYONE_ID_UNSAFE);

    return new Request(null, 1l, 0, opCode, ByteBuffer.wrap(baos.toByteArray()), ids);
}
 
开发者ID:l294265421,项目名称:ZooKeeper,代码行数:13,代码来源:PrepRequestProcessorTest.java

示例14: Packet

import org.apache.jute.Record; //导入依赖的package包/类
/** Convenience ctor */
Packet(RequestHeader requestHeader, ReplyHeader replyHeader,
       Record request, Record response,
       WatchRegistration watchRegistration) {
    this(requestHeader, replyHeader, request, response,
         watchRegistration, false);
}
 
开发者ID:maoling,项目名称:fuck_zookeeper,代码行数:8,代码来源:ClientCnxn.java

示例15: submitRequest

import org.apache.jute.Record; //导入依赖的package包/类
public ReplyHeader submitRequest(RequestHeader h, Record request,
        Record response, WatchRegistration watchRegistration)
        throws InterruptedException {
    ReplyHeader r = new ReplyHeader();
    //客户端和服务器之间进行网络传输的最小通信单位
    Packet packet = queuePacket(h, r, request, response, null, null, null,
                null, watchRegistration);
    synchronized (packet) {
        while (!packet.finished) {
            packet.wait();
        }
    }
    return r;
}
 
开发者ID:maoling,项目名称:fuck_zookeeper,代码行数:15,代码来源:ClientCnxn.java


注:本文中的org.apache.jute.Record类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。