Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void load(ByteBuffer byteBuffer, AsyncMethodCallback asyncMethodCallback) throws TException {
- System.out.println("Hello Kant");
- QueryOptions queryOptions = new QueryOptions();
- SocketOptions socketOptions = new SocketOptions();
- socketOptions.setReadTimeoutMillis(60000);
- queryOptions.setConsistencyLevel(ConsistencyLevel.ONE);
- Cluster cassandra = Cluster.builder().withClusterName("Test Cluster").addContactPoint("127.0.0.1").withPort(9042).withQueryOptions(queryOptions).withSocketOptions(socketOptions).build();
- System.out.println("Hello Kant1");
- ListenableFuture<Session> session = cassandra.connectAsync();
- System.out.println("Hello Kant2");
- ListenableFuture<Entity> resultEntity = Futures.transform(session, new AsyncFunction<Session, Entity>() {
- @Override
- public ListenableFuture<Entity> apply(Session session) throws Exception {
- System.out.println("Hello Kant3");
- MappingManager manager = new MappingManager(session);
- System.out.println("Hello Kant4");
- Mapper<Entity> mapper = manager.mapper(Entity.class);
- System.out.println("Hello Kant5");
- return mapper.getAsync(byteBuffer);
- }
- });
- ListenableFuture<LoadResponse> entityListenableFuture = Futures.transform(resultEntity, new Function<Entity, LoadResponse>() {
- @Override
- public LoadResponse apply(Entity result) {
- System.out.println("check2");
- LoadResponse response = new LoadResponse(PersistenceServiceStatus.OK);
- System.out.println("hello prashant 4");
- System.out.println(Bytes.toRawHexString(result.getDataIdentity()));
- response.setValue(result.getDataIdentity());
- return response;
- }
- });
- Futures.addCallback(entityListenableFuture, new FutureCallback<LoadResponse>() {
- @Override
- public void onSuccess(LoadResponse response) {
- System.out.println("Hello Prashant5");
- asyncMethodCallback.onComplete(response);
- }
- @Override
- public void onFailure(Throwable t) {
- System.out.println("error message -> " + t.getMessage());
- System.out.println("error cause -> " + t.getCause());
- t.printStackTrace();
- asyncMethodCallback.onError(new Exception("error message -> " + t.getMessage()));
- }
- });
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement