GemFire 中的增量传播

Delta Propagation in GemFire

当我尝试在 GemFire 中实现 Delta 传播时,出现如下所示的异常...

异常...

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>

@Vigneshwara-

Delta Propagation is not supported by PDX Serialization in GemFire. You must use the GemFire Data Serialization 框架(即 DataSerializableDataSerializers)改为 Deltas

简而言之...如果您使用 PDX,则不能使用 Deltas。如果你使用Deltas,那么你就不能使用PDX。

对不起, -j