Search in sources :

Example 1 with InterHubMessage

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;
}
Also used : MultiParentClassLoader(org.gradle.internal.classloader.MultiParentClassLoader) MultiParentClassLoader(org.gradle.internal.classloader.MultiParentClassLoader) CachingClassLoader(org.gradle.internal.classloader.CachingClassLoader) MethodInvocation(org.gradle.internal.dispatch.MethodInvocation) CachingClassLoader(org.gradle.internal.classloader.CachingClassLoader) InterHubMessage(org.gradle.internal.remote.internal.hub.protocol.InterHubMessage)

Example 2 with InterHubMessage

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()));
        }
    }
}
Also used : ArrayList(java.util.ArrayList) RejectedMessage(org.gradle.internal.remote.internal.hub.protocol.RejectedMessage) InterHubMessage(org.gradle.internal.remote.internal.hub.protocol.InterHubMessage) ChannelMessage(org.gradle.internal.remote.internal.hub.protocol.ChannelMessage)

Example 3 with InterHubMessage

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());
        }
    }
}
Also used : InterHubMessage(org.gradle.internal.remote.internal.hub.protocol.InterHubMessage)

Aggregations

InterHubMessage (org.gradle.internal.remote.internal.hub.protocol.InterHubMessage)3 ArrayList (java.util.ArrayList)1 CachingClassLoader (org.gradle.internal.classloader.CachingClassLoader)1 MultiParentClassLoader (org.gradle.internal.classloader.MultiParentClassLoader)1 MethodInvocation (org.gradle.internal.dispatch.MethodInvocation)1 ChannelMessage (org.gradle.internal.remote.internal.hub.protocol.ChannelMessage)1 RejectedMessage (org.gradle.internal.remote.internal.hub.protocol.RejectedMessage)1