Welcome to the new Gigaspaces XAP forum. To recover your account, please follow these instructions.

Ask Your Question
0

Custom mirror service and java classes clashes

Hello.

I have a problem. I need to persist class "ExampleClass" from one space to another space. But in another space (on another cluster and another LUS) - this class has another type of the "prop" field(in old - "Integer" as in example below, but in new - String).

I wrote custom mirror service with custom synchronization endpoint. In this class I use custom classloader for loading jar file with new version of "ExampleClass" and in synchronization endpoint class I use reflection for converting old class to new. And all is ok, but when I perform "write" operation to new space - I got the next error -

2014-10-22 19:18:56,989 mirror-pu [1] WARNING [com.gigaspaces.core.reflection] - Failed to generate ASM for constructor, falling back to standard reflection. class: com.ExampleClass; Caused by: java.lang.NoSuchMethodException: Failed generating ASM constructor wrapper: java.lang.ClassNotFoundException: com.ExampleClassGigaspacesCtor0 2014-10-22 19:18:56,992 mirror-pu [1] WARNING [com.gigaspaces.core.reflection] - Failed to generate ASM for properties, falling back to standard reflection. class: [com.ExampleClass].; Caused by: java.lang.NoSuchMethodException: Failed generating ASM properties wrapper: java.lang.ClassNotFoundException: com.ExampleClassGigaspacesProperties 2014-10-22 19:18:57,023 mirror-pu [1] INFO [com.gigaspaces.util.mirror.server.CustomSynchEndpoint] - Exception message = Unexpected exception: Cannot execute operation on partitioned cluster without routing value; nested exception is com.j_spaces.core.exception.internal.ProxyInternalSpaceException: Unexpected exception: Cannot execute operation on partitioned cluster without routing value

ExampleClass -

   public class ExampleClass implements ISpaceClass {

   private static final long serialVersionUID = -4135626947314736891L;
   String key;
   Integer prop;

   public ExampleClass() {
   }

   @SpaceId(autoGenerate = true)
   @SpaceRouting
   public String getKey() {
      return spaceKey;
   }

   public void setKey(String key) {
      this.key = key;
   }

  public void setProp(Integer prop) {
      this.prop=prop;
  }

  public Integer getProp() {
      return this.prop;
  }
}

Why I got this exception and how I can fix it?

asked 2014-10-23 06:19:33 -0600

ssherbakov gravatar image
edit retag flag offensive close merge delete

3 Answers

Sort by ยป oldest newest most voted
0

You will have to use Document API with the mirror and when interacting with the other space. You can configure the mirror to produce document objects and not POJO objects. See for example the cassandra mirror configuration.

This will avoid class clashing as the actual space class will not be loaded into the mirror PU classloader.

answered 2014-10-23 09:53:22 -0600

shay hassidim gravatar image
edit flag offensive delete link more

Comments

Thank you. But if I can't redeploy source space for add document support - how I can add document type in the mirror? And how I can produce document to remote space? I got next exception after I tried - "java.lang.IllegalArgumentException: Space types can only be introduced on embedded Space"

ssherbakov gravatar imagessherbakov ( 2014-10-23 10:29:16 -0600 )edit

The SpaceSynchronizationEndpoint used by the Mirror should use the following to use Document instead of POJO: http://www.gigaspaces.com/docs/JavaDo...

shay hassidim gravatar imageshay hassidim ( 2014-10-23 15:26:29 -0600 )edit
0

You can introduce a new Document using:

SpaceTypeDescriptor typeDescriptor = new SpaceTypeDescriptorBuilder("Product")
        .idProperty("CatalogNumber")
        .routingProperty("Category")
        .addPropertyIndex("Name", SpaceIndexType.BASIC)
        .addPropertyIndex("Price", SpaceIndexType.EXTENDED)
        .create();
    // Register type:
    gigaspace.getTypeManager().registerTypeDescriptor(typeDescriptor);

In general once a space class been introduced to the space (done implicitly via any space operation - for example dummy read operation that returns nothing or initial load) - you can access it via Document API without registering it.

See the QueryResultType: http://docs.gigaspaces.com/xap100/doc...

SpaceDocument document = gigaSpace.readById(
    new IdQuery<SpaceDocument>(Product.class.getName(), 7,
        QueryResultType.DOCUMENT));

answered 2014-10-23 15:20:05 -0600

shay hassidim gravatar image
edit flag offensive delete link more
0

You will have to use Document API with the mirror and when interacting with the other space. You can configure the mirror to produce document objects and not POJO objects. See for example the cassandra mirror configuration.

This will avoid class clashing as the actual space class will not be loaded into the mirror PU classloader.

You will have to use Document API with the mirror and when interacting with the other space. You can configure the mirror to produce document objects and not POJO objects. See for example the cassandra mirror configuration.

This will avoid class clashing as the actual space class will not be loaded into the mirror PU classloader.

You will have to use Document API with the mirror and when interacting with the other space. You can configure the mirror to produce document objects and not POJO objects. See for example the cassandra mirror configuration.

This will avoid class clashing as the actual space class will not be loaded into the mirror PU classloader.

answered 2014-10-26 12:06:16 -0600

shay hassidim gravatar image

updated 2014-10-26 12:48:58 -0600

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2014-10-23 06:19:33 -0600

Seen: 830 times

Last updated: Oct 26 '14