Распространение дельты в GemFire

Когда я пытался реализовать дельта-распространение в GemFire, я получал исключение, показанное ниже...

Исключение...

com.gemstone.gemfire.pdx.PdxSerializationException: Could not create an instance of a class DeltaTesting with root cause
java.lang.ClassNotFoundException: DeltaTesting
    at org.apache.geode.internal.ClassPathLoader.forName(ClassPathLoader.java:437)
    at org.apache.geode.internal.InternalDataSerializer.getCachedClass(InternalDataSerializer.java:4010)
    at org.apache.geode.pdx.internal.PdxType.getPdxClass(PdxType.java:235)
    at org.apache.geode.pdx.internal.PdxReaderImpl.basicGetObject(PdxReaderImpl.java:687)
    at org.apache.geode.pdx.internal.PdxReaderImpl.getObject(PdxReaderImpl.java:682)

Код...

@Region("deltaTesting")
public class DeltaTesting implements Delta,Serializable {

    private static final long serialVersionUID = 1L;

    public DeltaTesting(){

    }

public DeltaTesting(String id, String firstName, String lastName){
    this.id = id;
    this.firstName = firstName;
    this.lastName = lastName;

    }


    @Id
    private String id;
    private String firstName;
    private String lastName;


    private transient boolean stringId = false;
    private transient boolean stringFirstName = false;
    private transient boolean stringLastName = false;



    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.stringId = true;
        this.id = id;
    }

    public String getFirstName() {
        return firstName;
    }

    public void setFirstName(String firstName) {
        this.stringFirstName = true;
        this.firstName = firstName;
    }

    public String getLastName() {
        return lastName;
    }

    public void setLastName(String lastName) {
        this.stringLastName = true;
        this.lastName = lastName;
    }

    @Override
    public void fromDelta(DataInput in) throws IOException, InvalidDeltaException {
        // TODO Auto-generated method stub

         System.out.println("Applying delta to " + this.toString());
            // For each field, read whether there is a change 
            if (in.readBoolean()) {
                // Read the change and apply it to the object 
                this.id = in.readLine();
                System.out.println(" Applied delta to field 'id' = "
                            + this.id);
            }

            if (in.readBoolean()) {
                // Read the change and apply it to the object 
                this.firstName = in.readLine();
                System.out.println(" Applied delta to field 'firstname' = "
                            + this.firstName);
            }
            if (in.readBoolean()) {
                // Read the change and apply it to the object 
                this.lastName = in.readLine();
                System.out.println(" Applied delta to field 'lastname' = "
                            + this.lastName);
            }
    }


    @Override
    public boolean hasDelta() {
        // TODO Auto-generated method stub
         return this.stringId || this.stringFirstName || this.stringLastName;
    }


    @Override
    public void toDelta(DataOutput out) throws IOException {

         out.writeBoolean(stringId);
        // TODO Auto-generated method stub
        if (stringId) {
            out.writeBytes(this.id);
            this.stringId = false;
            System.out.println(" Extracted delta from field 'id' = " + this.id);
        }
         out.writeBoolean(stringFirstName);
        if (stringFirstName) {
            out.writeBytes(this.firstName);
            this.stringFirstName = false;
            System.out.println(" Extracted delta from field 'firstName' = " + this.firstName);
        }
         out.writeBoolean(stringLastName);
            if (stringLastName) {
                out.writeBytes(this.lastName);
                this.stringLastName = false;
                System.out.println(" Extracted delta from field 'lastName' = " + this.lastName);
            }

    }



}
**cache.xml**   
    <pdx>
    <pdx-serializer>
    <class-name>com.gemstone.gemfire.pdx.ReflectionBasedAutoSerializer</class-
    name>
   <parameter name="classes">
   <string>com\.xxx\..+</string>
   </parameter> 

</pdx-serializer>
   </pdx>

person Vigneshwaran    schedule 08.06.2017    source источник


Ответы (1)


@Вигнешвара-

Дельта-распространение не поддерживается с помощью сериализации PDX в GemFire. Вы должны использовать платформу GemFire ​​сериализации данных (т. е. DataSerializable и DataSerializers) вместо Deltas.

Короче говоря... если вы используете PDX, вы не можете использовать Deltas. Если вы используете Deltas, вы не можете использовать PDX.

Извините, -j

person John Blum    schedule 08.06.2017
comment
Спасибо, Джон. Отсутствует пример кода для реализации DataSerializable или DataSerializers с Deltas. - person Vigneshwaran; 08.06.2017