本文整理匯總了Java中org.apache.thrift.protocol.TCompactProtocol類的典型用法代碼示例。如果您正苦於以下問題:Java TCompactProtocol類的具體用法?Java TCompactProtocol怎麽用?Java TCompactProtocol使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
TCompactProtocol類屬於org.apache.thrift.protocol包,在下文中一共展示了TCompactProtocol類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: benchSetup
import org.apache.thrift.protocol.TCompactProtocol; //導入依賴的package包/類
@Setup(Level.Trial)
public void benchSetup(BenchmarkParams params) throws TException {
testObject = new ThriftTestObject();
testObject.addToField1(createElement("1"));
testObject.addToField1(createElement("2"));
testObject.addToField1(createElement("3"));
testObject.addToField1(createElement("4"));
testObject.addToField1(createElement("1"));
testObject.addToField1(createElement("2"));
testObject.addToField1(createElement("3"));
testObject.addToField1(createElement("4"));
testObject.addToField1(createElement("1"));
testObject.addToField1(createElement("2"));
testObject.addToField1(createElement("3"));
testObject.addToField1(createElement("4"));
testObject.addToField1(createElement("1"));
testObject.addToField1(createElement("2"));
testObject.addToField1(createElement("3"));
testObject.addToField1(createElement("4"));
serializer = new TSerializer(new TCompactProtocol.Factory());
deserializer = new TDeserializer(new TCompactProtocol.Factory());
testData = serializer.serialize(testObject);
}
示例2: checkAndCreateAdminUser
import org.apache.thrift.protocol.TCompactProtocol; //導入依賴的package包/類
private void checkAndCreateAdminUser() throws TException {
THttpClient thriftClient = new THttpClient(thriftServerUrl + "/users/thrift");
TProtocol protocol = new TCompactProtocol(thriftClient);
UserService.Iface userClient = new UserService.Client(protocol);
User admin = new User("admin", "[email protected]", "SW360 Administration");
admin.setFullname("John Doe");
admin.setGivenname("John");
admin.setLastname("Doe");
admin.setUserGroup(UserGroup.ADMIN);
try {
userClient.getByEmail("[email protected]");
System.out.println("sw360 admin user already exists");
} catch (Exception e) {
System.out.println("creating admin user => " + userClient.addUser(admin));
}
}
示例3: benchSetup
import org.apache.thrift.protocol.TCompactProtocol; //導入依賴的package包/類
@Setup(Level.Trial)
public void benchSetup(BenchmarkParams params) throws TException {
testObject = new ThriftTestObject();
testObject.addToField1(createElement("1"));
testObject.addToField1(createElement("2"));
testObject.addToField1(createElement("3"));
testObject.addToField1(createElement("4"));
testObject.addToField1(createElement("1"));
testObject.addToField1(createElement("2"));
testObject.addToField1(createElement("3"));
testObject.addToField1(createElement("4"));
testObject.addToField1(createElement("1"));
testObject.addToField1(createElement("2"));
testObject.addToField1(createElement("3"));
testObject.addToField1(createElement("4"));
testObject.addToField1(createElement("1"));
testObject.addToField1(createElement("2"));
testObject.addToField1(createElement("3"));
testObject.addToField1(createElement("4"));
byteArrayOutputStream = new ByteArrayOutputStream();
TCompactProtocol.Factory protocolFactory = new TCompactProtocol.Factory();
protocol = protocolFactory.getProtocol(new TIOStreamTransport(byteArrayOutputStream));
}
示例4: benchSetup
import org.apache.thrift.protocol.TCompactProtocol; //導入依賴的package包/類
@Setup(Level.Trial)
public void benchSetup(BenchmarkParams params) throws TException {
ThriftTestWriteObject testObject = new ThriftTestWriteObject();
testObject.setField1(Arrays.asList("1", "2", "3", "4", "5",
"1", "2", "3", "4", "5",
"1", "2", "3", "4", "5"));
HashMap<String, List<String>> field2 = new HashMap<>();
field2.put("1", Arrays.asList("1", "2", "3", "4", "5"));
field2.put("2", Arrays.asList("1", "2", "3", "4", "5"));
field2.put("3", Arrays.asList("1", "2", "3", "4", "5"));
testObject.setField2(field2);
testObject.setField3("x-3");
serializer = new TSerializer(new TCompactProtocol.Factory());
deserializer = new TDeserializer(new TCompactProtocol.Factory());
testData = serializer.serialize(testObject);
}
示例5: benchSetup
import org.apache.thrift.protocol.TCompactProtocol; //導入依賴的package包/類
@Setup(Level.Trial)
public void benchSetup(BenchmarkParams params) throws TException {
testObject = new ThriftTestObject();
testObject.addToField1(31.415926);
testObject.addToField1(61.415923);
testObject.addToField1(31.415269);
testObject.addToField1(53.141926);
testObject.addToField1(13.145926);
testObject.addToField1(43.115926);
testObject.addToField1(31.419265);
testObject.addToField1(23.141596);
testObject.addToField1(43.161592);
testObject.addToField1(0.112);
byteArrayOutputStream = new ByteArrayOutputStream();
TCompactProtocol.Factory protocolFactory = new TCompactProtocol.Factory();
protocol = protocolFactory.getProtocol(new TIOStreamTransport(byteArrayOutputStream));
}
示例6: benchSetup
import org.apache.thrift.protocol.TCompactProtocol; //導入依賴的package包/類
@Setup(Level.Trial)
public void benchSetup(BenchmarkParams params) throws TException {
testObject = new ThriftTestObject();
testObject.addToField1(31.415926);
testObject.addToField1(61.415923);
testObject.addToField1(31.415269);
testObject.addToField1(53.141926);
testObject.addToField1(13.145926);
testObject.addToField1(43.115926);
testObject.addToField1(31.419265);
testObject.addToField1(23.141596);
testObject.addToField1(43.161592);
testObject.addToField1(0.112);
serializer = new TSerializer(new TCompactProtocol.Factory());
deserializer = new TDeserializer(new TCompactProtocol.Factory());
testData = serializer.serialize(testObject);
}
示例7: benchSetup
import org.apache.thrift.protocol.TCompactProtocol; //導入依賴的package包/類
@Setup(Level.Trial)
public void benchSetup(BenchmarkParams params) throws TException {
testObject = new ThriftTestObject();
testObject.setField1("1");
testObject.setField2("2");
testObject.setField3("3");
testObject.setField4("4");
testObject.setField5("5");
testObject.setField6("6");
testObject.setField7("7");
testObject.setField8("8");
testObject.setField9("9");
testObject.setField10("10");
byteArrayOutputStream = new ByteArrayOutputStream();
TCompactProtocol.Factory protocolFactory = new TCompactProtocol.Factory();
protocol = protocolFactory.getProtocol(new TIOStreamTransport(byteArrayOutputStream));
}
示例8: benchSetup
import org.apache.thrift.protocol.TCompactProtocol; //導入依賴的package包/類
@Setup(Level.Trial)
public void benchSetup(BenchmarkParams params) throws TException {
testObject = new ThriftTestObject();
testObject.setField1(31.415926);
testObject.setField2(61.415923);
testObject.setField3(31.415269);
testObject.setField4(53.141926);
testObject.setField5(13.145926);
testObject.setField6(43.115926);
testObject.setField7(31.419265);
testObject.setField8(23.141596);
testObject.setField9(43.161592);
testObject.setField10(0.112);
byteArrayOutputStream = new ByteArrayOutputStream();
TCompactProtocol.Factory protocolFactory = new TCompactProtocol.Factory();
protocol = protocolFactory.getProtocol(new TIOStreamTransport(byteArrayOutputStream));
}
示例9: benchSetup
import org.apache.thrift.protocol.TCompactProtocol; //導入依賴的package包/類
@Setup(Level.Trial)
public void benchSetup(BenchmarkParams params) throws TException {
testObject = new ThriftTestObject();
testObject.addToField1(321);
testObject.addToField1(123);
testObject.addToField1(132);
testObject.addToField1(312);
testObject.addToField1(321);
testObject.addToField1(123);
testObject.addToField1(132);
testObject.addToField1(312);
testObject.addToField1(321);
testObject.addToField1(123);
testObject.addToField1(132);
testObject.addToField1(312);
testObject.addToField1(321);
testObject.addToField1(123);
testObject.addToField1(132);
testObject.addToField1(312);
byteArrayOutputStream = new ByteArrayOutputStream();
TCompactProtocol.Factory protocolFactory = new TCompactProtocol.Factory();
protocol = protocolFactory.getProtocol(new TIOStreamTransport(byteArrayOutputStream));
}
示例10: benchSetup
import org.apache.thrift.protocol.TCompactProtocol; //導入依賴的package包/類
@Setup(Level.Trial)
public void benchSetup(BenchmarkParams params) throws TException {
testObject = new ThriftTestObject();
testObject.setField1(31415926);
testObject.setField2(61415923);
testObject.setField3(31415269);
testObject.setField4(53141926);
testObject.setField5(13145926);
testObject.setField6(43115926);
testObject.setField7(31419265);
testObject.setField8(23141596);
testObject.setField9(43161592);
testObject.setField10(112);
byteArrayOutputStream = new ByteArrayOutputStream();
TCompactProtocol.Factory protocolFactory = new TCompactProtocol.Factory();
protocol = protocolFactory.getProtocol(new TIOStreamTransport(byteArrayOutputStream));
}
示例11: benchSetup
import org.apache.thrift.protocol.TCompactProtocol; //導入依賴的package包/類
@Setup(Level.Trial)
public void benchSetup(BenchmarkParams params) throws TException {
testObject = new ThriftTestObject();
testObject.setField1(31415926);
testObject.setField2(61415923);
testObject.setField3(31415269);
testObject.setField4(53141926);
testObject.setField5(13145926);
testObject.setField6(43115926);
testObject.setField7(31419265);
testObject.setField8(23141596);
testObject.setField9(43161592);
testObject.setField10(112);
serializer = new TSerializer(new TCompactProtocol.Factory());
deserializer = new TDeserializer(new TCompactProtocol.Factory());
testData = serializer.serialize(testObject);
}
示例12: nonBlockMode
import org.apache.thrift.protocol.TCompactProtocol; //導入依賴的package包/類
private void nonBlockMode() {
AskerHandler handler = new AskerHandler();
Asker.Processor processor = new Asker.Processor(handler);
try {
TNonblockingServerTransport transport = new TNonblockingServerSocket(port);
THsHaServer.Args arg = new THsHaServer.Args(transport);
arg.protocolFactory(new TCompactProtocol.Factory());
// arg.transportFactory(new TFramedTransport.Factory());
// arg.processorFactory(new TProcessorFactory(processor));
arg.processor(processor);
server = new THsHaServer(arg);
start.countDown();
System.out.println("Starting the nonBlock server...");
server.serve();
} catch (Exception e) {
e.printStackTrace();
}
}
示例13: testBlockSync
import org.apache.thrift.protocol.TCompactProtocol; //導入依賴的package包/類
@Test
public void testBlockSync() throws TException {
AskerServer server = new AskerServer(port, true);
server.start();
try (TTransport transport = transport(port)) {
transport.open();
TProtocol protocol = new TCompactProtocol(transport);
final Asker.Client client = new Asker.Client(protocol);
Helper helper = new Helper(collector);
helper.checkEcho(client);
helper.checkCount(client);
helper.checkReverse(client);
helper.checkUpperCast(client);
helper.checkLowerCast(client);
helper.checkRandom(client, 5 + random.nextInt(10));
}
server.stop();
}
示例14: testNonBlockSync
import org.apache.thrift.protocol.TCompactProtocol; //導入依賴的package包/類
@Test
public void testNonBlockSync() throws TException {
AskerServer server = new AskerServer(port, false);
server.start();
try (TTransport transport = new TFramedTransport(transport(port))) {
transport.open();
TProtocol protocol = new TCompactProtocol(transport);
final Asker.Client client = new Asker.Client(protocol);
Helper helper = new Helper(collector);
helper.checkEcho(client);
helper.checkCount(client);
helper.checkReverse(client);
helper.checkUpperCast(client);
helper.checkLowerCast(client);
helper.checkRandom(client, 5 + random.nextInt(10));
}
server.stop();
}
示例15: testAsync
import org.apache.thrift.protocol.TCompactProtocol; //導入依賴的package包/類
@Test
@Ignore
public void testAsync() throws TException, IOException, ExecutionException, InterruptedException {
AskerServer server = new AskerServer(port, false);
server.start();
try (SocketChannel socketChannel = SocketChannel.open()) {
socketChannel.connect(new InetSocketAddress("localhost", port));
TNonblockingTransport transport = new TNonblockingSocket(socketChannel);
final Asker.AsyncClient client = new Asker.AsyncClient(
new TCompactProtocol.Factory(),
new TAsyncClientManager(), transport);
Helper helper = new Helper(collector);
helper.checkEcho(client);
helper.checkCount(client);
helper.checkReverse(client);
helper.checkUpperCast(client);
helper.checkLowerCast(client);
helper.checkRandom(client, 5 + random.nextInt(10));
}
server.stop();
}