本文整理汇总了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();
}