List of usage examples for org.apache.thrift.protocol TCompactProtocol TCompactProtocol
public TCompactProtocol(TTransport transport)
From source file:org.diqube.ui.websocket.request.JsonRequest.java
License:Open Source License
@PostConstruct public void initialize() { commandClusterInteraction = new AbstractCommandClusterInteraction(config, ticket) { @Override/*from w ww . j ava2 s . c om*/ protected void registerQueryThriftResultCallback(Pair<String, Short> node, UUID queryUuid, Iface resultHandler) { queryResultRegistry.registerThriftResultCallback(session, requestId, node, queryUuid, resultHandler); cleanupActions.add(() -> queryResultRegistry.unregisterQuery(requestId, queryUuid)); } @Override protected Pair<UUID, Pair<String, Short>> findQueryUuidAndServerAddr() { UUID queryUuid = queryResultRegistry.getQueryUuid(session, requestId); Pair<String, Short> node = queryResultRegistry.getDiqubeServerAddr(queryUuid); if (queryUuid == null || node == null) return null; return new Pair<>(queryUuid, node); } @Override protected <T extends TServiceClient> T openConnection(Class<? extends T> thriftClientClass, String serviceName, Pair<String, Short> node) { TTransport transport = new TFramedTransport(new TSocket(node.getLeft(), node.getRight())); TProtocol protocol = new TMultiplexedProtocol(new TCompactProtocol(transport), serviceName); T res; try { res = thriftClientClass.getConstructor(TProtocol.class).newInstance(protocol); } catch (InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException | NoSuchMethodException | SecurityException e) { throw new RuntimeException("Could not instantiate thrift client", e); } try { transport.open(); } catch (TTransportException e) { return null; } cleanupActions.add(() -> transport.close()); return res; } }; }
From source file:org.eclipse.sw360.attachments.TestAttachmentClient.java
License:Open Source License
public static void main(String[] args) { try {/* ww w .j a v a 2 s .c o m*/ THttpClient thriftClient = new THttpClient("http://127.0.0.1:8080/attachmentservice/thrift"); TProtocol protocol = new TCompactProtocol(thriftClient); AttachmentService.Iface client = new AttachmentService.Client(protocol); } catch (Exception e) { assert (false); } }
From source file:org.eclipse.sw360.moderation.TestModerationClient.java
License:Open Source License
public static void main(String[] args) throws TException, IOException { THttpClient thriftClient = new THttpClient("http://127.0.0.1:8080//moderation/thrift"); TProtocol protocol = new TCompactProtocol(thriftClient); ModerationService.Iface client = new ModerationService.Client(protocol); List<ModerationRequest> requestsByModerator = client.getRequestsByModerator( new User().setId("58245y9845").setEmail("cedric.bodet@tngtech.com").setDepartment("BB")); System.out/*from w ww. j a v a2s . com*/ .println("Fetched " + requestsByModerator.size() + " moderation requests from moderation service"); }
From source file:org.eclipse.sw360.rest.demo.DemoApplication.java
License:Open Source License
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", "admin@sw360.org", "SW360 Administration"); admin.setFullname("John Doe"); admin.setGivenname("John"); admin.setLastname("Doe"); admin.setUserGroup(UserGroup.ADMIN); try {//w w w . j av a 2s. c o m userClient.getByEmail("admin@sw360.org"); System.out.println("sw360 admin user already exists"); } catch (Exception e) { System.out.println("creating admin user => " + userClient.addUser(admin)); } }
From source file:org.eclipse.sw360.rest.resourceserver.attachment.Sw360AttachmentService.java
License:Open Source License
private AttachmentService.Iface getThriftAttachmentClient() throws TTransportException { THttpClient thriftClient = new THttpClient(thriftServerUrl + "/attachments/thrift"); TProtocol protocol = new TCompactProtocol(thriftClient); return new AttachmentService.Client(protocol); }
From source file:org.eclipse.sw360.rest.resourceserver.component.Sw360ComponentService.java
License:Open Source License
private ComponentService.Iface getThriftComponentClient() throws TTransportException { THttpClient thriftClient = new THttpClient(thriftServerUrl + "/components/thrift"); TProtocol protocol = new TCompactProtocol(thriftClient); return new ComponentService.Client(protocol); }
From source file:org.eclipse.sw360.rest.resourceserver.license.Sw360LicenseService.java
License:Open Source License
private LicenseService.Iface getThriftLicenseClient() throws TTransportException { THttpClient thriftClient = new THttpClient(thriftServerUrl + "/licenses/thrift"); TProtocol protocol = new TCompactProtocol(thriftClient); return new LicenseService.Client(protocol); }
From source file:org.eclipse.sw360.rest.resourceserver.licenseinfo.Sw360LicenseInfoService.java
License:Open Source License
private LicenseInfoService.Iface getThriftLicenseInfoClient() throws TTransportException { THttpClient thriftClient = new THttpClient(thriftServerUrl + "/licenseinfo/thrift"); TProtocol protocol = new TCompactProtocol(thriftClient); return new LicenseInfoService.Client(protocol); }
From source file:org.eclipse.sw360.rest.resourceserver.project.Sw360ProjectService.java
License:Open Source License
private ProjectService.Iface getThriftProjectClient() throws TTransportException { THttpClient thriftClient = new THttpClient(thriftServerUrl + "/projects/thrift"); TProtocol protocol = new TCompactProtocol(thriftClient); return new ProjectService.Client(protocol); }
From source file:org.eclipse.sw360.rest.resourceserver.user.Sw360UserService.java
License:Open Source License
private UserService.Iface getThriftUserClient() throws TTransportException { THttpClient thriftClient = new THttpClient(thriftServerUrl + "/users/thrift"); TProtocol protocol = new TCompactProtocol(thriftClient); return new UserService.Client(protocol); }