use of org.gradle.internal.remote.internal.hub.protocol.InterHubMessage in project gradle by gradle.
the class MessageHubBackedObjectConnection method connect.
public void connect() {
ClassLoader methodParamClassLoader;
if (methodParamClassLoaders.size() == 0) {
methodParamClassLoader = getClass().getClassLoader();
} else if (methodParamClassLoaders.size() == 1) {
methodParamClassLoader = CollectionUtils.single(methodParamClassLoaders);
} else {
methodParamClassLoader = new CachingClassLoader(new MultiParentClassLoader(methodParamClassLoaders));
}
MethodArgsSerializer argsSerializer = new DefaultMethodArgsSerializer(paramSerializers, new JavaSerializationBackedMethodArgsSerializer(methodParamClassLoader));
StatefulSerializer<InterHubMessage> serializer = new InterHubMessageSerializer(new TypeSafeSerializer<MethodInvocation>(MethodInvocation.class, new MethodInvocationSerializer(methodParamClassLoader, argsSerializer)));
connection = completion.create(serializer);
hub.addConnection(connection);
hub.noFurtherConnections();
completion = null;
}
use of org.gradle.internal.remote.internal.hub.protocol.InterHubMessage in project gradle by gradle.
the class OutgoingQueue method discardQueued.
void discardQueued() {
List<InterHubMessage> rejected = new ArrayList<InterHubMessage>();
drain(rejected);
for (InterHubMessage message : rejected) {
if (message instanceof ChannelMessage) {
ChannelMessage channelMessage = (ChannelMessage) message;
incomingQueue.queue(new RejectedMessage(channelMessage.getChannel(), channelMessage.getPayload()));
}
}
}
use of org.gradle.internal.remote.internal.hub.protocol.InterHubMessage in project gradle by gradle.
the class MultiEndPointQueue method flush.
private void flush() {
// TODO - need to do a better job of routing messages when there are multiple endpoints. This is just going to forward all queued messages to the first
// waiting endpoint, even if there are multiple waiting to do work
EndPointQueue selected = waiting.isEmpty() ? null : waiting.get(0);
while (!queue.isEmpty()) {
InterHubMessage message = queue.get(0);
switch(message.getDelivery()) {
case Stateful:
case AllHandlers:
if (endpoints.isEmpty()) {
return;
}
if (message.getDelivery() == InterHubMessage.Delivery.Stateful) {
initializer.onStatefulMessage(message);
}
for (EndPointQueue endpoint : endpoints) {
endpoint.dispatch(message);
}
queue.remove(0);
waiting.clear();
continue;
case SingleHandler:
if (selected == null) {
return;
}
queue.remove(0);
waiting.remove(selected);
selected.dispatch(message);
break;
default:
throw new IllegalArgumentException("Unknown delivery type: " + message.getDelivery());
}
}
}
Aggregations