use of com.google.spanner.v1.CreateSessionRequest in project grpc-gcp-java by GoogleCloudPlatform.
the class SpannerLoadTest method createFutureSessions.
private static List<String> createFutureSessions(SpannerFutureStub stub) throws ExecutionException, InterruptedException {
List<ListenableFuture<Session>> futures = new ArrayList<>();
List<String> futureNames = new ArrayList<>();
// Check CreateSession with multiple channels and streams,
CreateSessionRequest req = CreateSessionRequest.newBuilder().setDatabase(DATABASE).build();
for (int i = 0; i < MAX_CHANNEL * MAX_STREAM / 2; i++) {
ListenableFuture<Session> future = stub.createSession(req);
futures.add(future);
}
for (ListenableFuture<Session> future : futures) {
futureNames.add(future.get().getName());
}
return futureNames;
}
use of com.google.spanner.v1.CreateSessionRequest in project swiftmq-client by iitsoftware.
the class QueueConnectionImpl method createQueueSession.
public QueueSession createQueueSession(boolean transacted, int acknowledgeMode) throws JMSException {
verifyState();
SessionImpl queueSession = null;
CreateSessionReply reply = null;
try {
reply = (CreateSessionReply) requestRegistry.request(new CreateSessionRequest(0, transacted, acknowledgeMode, CreateSessionRequest.QUEUE_SESSION, 0));
} catch (Exception e) {
throw ExceptionConverter.convert(e);
}
if (reply.isOk()) {
int dispatchId = reply.getSessionDispatchId();
queueSession = new SessionImpl(SessionImpl.TYPE_QUEUE_SESSION, this, transacted, acknowledgeMode, dispatchId, requestRegistry, myHostname, null);
queueSession.setUserName(getUserName());
queueSession.setMyDispatchId(addRequestService(queueSession));
addSession(queueSession);
} else {
throw ExceptionConverter.convert(reply.getException());
}
return (queueSession);
}
use of com.google.spanner.v1.CreateSessionRequest in project swiftmq-client by iitsoftware.
the class TopicConnectionImpl method createTopicSession.
public TopicSession createTopicSession(boolean transacted, int acknowledgeMode) throws JMSException {
verifyState();
SessionImpl topicSession = null;
CreateSessionReply reply = null;
try {
reply = (CreateSessionReply) requestRegistry.request(new CreateSessionRequest(0, transacted, acknowledgeMode, CreateSessionRequest.TOPIC_SESSION, 0));
} catch (Exception e) {
throw ExceptionConverter.convert(e);
}
if (reply.isOk()) {
int dispatchId = reply.getSessionDispatchId();
String cid = clientID != null ? clientID : internalCID;
topicSession = new SessionImpl(SessionImpl.TYPE_TOPIC_SESSION, this, transacted, acknowledgeMode, dispatchId, requestRegistry, myHostname, cid);
topicSession.setUserName(userName);
topicSession.setMyDispatchId(addRequestService(topicSession));
addSession(topicSession);
} else {
throw ExceptionConverter.convert(reply.getException());
}
return (topicSession);
}
use of com.google.spanner.v1.CreateSessionRequest in project swiftmq-client by iitsoftware.
the class TopicConnectionImpl method createTopicSession.
public TopicSession createTopicSession(boolean transacted, int acknowledgeMode) throws JMSException {
verifyState();
SessionImpl topicSession = null;
CreateSessionReply reply = null;
try {
reply = (CreateSessionReply) requestRegistry.request(new CreateSessionRequest(0, transacted, acknowledgeMode, CreateSessionRequest.TOPIC_SESSION, 0));
} catch (Exception e) {
throw ExceptionConverter.convert(e);
}
if (reply.isOk()) {
int dispatchId = reply.getSessionDispatchId();
String cid = clientID != null ? clientID : internalCID;
topicSession = new SessionImpl(SessionImpl.TYPE_TOPIC_SESSION, this, transacted, acknowledgeMode, dispatchId, requestRegistry, myHostname, cid);
topicSession.setUserName(userName);
topicSession.setMyDispatchId(addRequestService(topicSession));
addSession(topicSession);
} else {
throw ExceptionConverter.convert(reply.getException());
}
return (topicSession);
}
use of com.google.spanner.v1.CreateSessionRequest in project swiftmq-client by iitsoftware.
the class QueueConnectionImpl method createQueueSession.
public QueueSession createQueueSession(boolean transacted, int acknowledgeMode) throws JMSException {
verifyState();
SessionImpl queueSession = null;
CreateSessionReply reply = null;
try {
reply = (CreateSessionReply) requestRegistry.request(new CreateSessionRequest(0, transacted, acknowledgeMode, CreateSessionRequest.QUEUE_SESSION, 0));
} catch (Exception e) {
throw ExceptionConverter.convert(e);
}
if (reply.isOk()) {
int dispatchId = reply.getSessionDispatchId();
queueSession = new SessionImpl(SessionImpl.TYPE_QUEUE_SESSION, this, transacted, acknowledgeMode, dispatchId, requestRegistry, myHostname, null);
queueSession.setUserName(getUserName());
queueSession.setMyDispatchId(addRequestService(queueSession));
addSession(queueSession);
} else {
throw ExceptionConverter.convert(reply.getException());
}
return (queueSession);
}
Aggregations