Skip to content

Conversation

@Fuud
Copy link
Contributor

@Fuud Fuud commented Aug 14, 2023

Class will be eligible to transparent-rmi if:

  1. it is implementing marked interface java.rmi.Remote
  2. object of this class is wrapped with Cloud::createRmiProxy

For exapmle, take a look at test: https://github.com/gridkit/nanocloud/pull/39/files#diff-b3d424985422fd195ad32149e97b0876a961f3b2793f6b4f425714673612cd6eL855

It allows to transparently pass objects between nodes without extracting interfaces (useful for 3rd party objects).

Also it fixes following typing problem:

public class TestStarter {
    interface RemoteSupplier extends Remote{
        int get();
    }

    static class MyRemoteSupplier implements RemoteSupplier{
        @Override
        public int get() {
            return 0;
        }
    }

    public static void main(String[] args) {
        Cloud cloud = CloudFactory.createCloud();

        ViNode node = cloud.node("node");
        ViProps.at(node).setLocalType();

        final MyRemoteSupplier remoteSupplier = new MyRemoteSupplier();

        node.exec(new Runnable() {
            @Override
            public void run() {
                remoteSupplier.get();
            }
        });

    }
}

Before this patch will result in: java.lang.IllegalArgumentException: Can not set final TestStarter$MyRemoteSupplier field TestStarter$1.val$remoteSupplier to $Proxy1
It was because classes was passed as set of interfaces.

Now rmi classes passed as classes and proxy created as subclass of passed objects.

To implement this PR I have added two libraries: bytebuddy and objenesis. Both are shaded into resulting jar and will not conflict with other versions in classpath.

Class will be eligible to transparent-rmi if:
1) it is implementing marked interface java.rmi.Remote
2) object of this class is wrapped with Cloud::createRmiProxy
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant