[
https://issues.apache.org/jira/browse/GEODE-3541?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16147681#comment-16147681
]
Jared Stewart commented on GEODE-3541:
--------------------------------------
For context, here is the EvenOddPartitionResolver:
{noformat}
package org.apache.geode.examples.functions;
import java.io.Serializable;
import org.apache.geode.cache.EntryOperation;
import org.apache.geode.cache.PartitionResolver;
public class EvenOddPartitionResolver implements PartitionResolver<Integer,
String> {
public static final String ID =
EvenOddPartitionResolver.class.getSimpleName();
@Override
public String getName() {
return ID;
}
@Override
public Serializable getRoutingObject(EntryOperation<Integer, String>
opDetails) {
Integer integer = (Integer)opDetails.getKey();
if (integer != null && ((integer.intValue() % 2) == 1)) {
return "ODD";
}
return "EVEN";
}
@Override
public void close() {
// Intentionally left blank.
}
}
{noformat}
> Add GFSH api for creating regions with a FixedPartitionResolver
> ---------------------------------------------------------------
>
> Key: GEODE-3541
> URL: https://issues.apache.org/jira/browse/GEODE-3541
> Project: Geode
> Issue Type: New Feature
> Components: gfsh
> Reporter: Jared Stewart
>
> From a user:
> I was trying to get a custom partition resolver example working. The way
> geode-examples works is by configuring the servers via gfsh so I used:
> {noformat}create region --name=example-region --type=PARTITION
> --partition-resolver=org.apache.geode.examples.functions.EvenOddPartitionResolver
> --redundant-copies=0{noformat}
> Alas, this didn't work. [Jared: note - this was likely due to
> https://issues.apache.org/jira/browse/GEODE-3460] I found a way to get it to
> work in Java:
> {noformat} PartitionAttributesFactory partitionAttributesFactory = new
> PartitionAttributesFactory();
> partitionAttributesFactory
>
> .addFixedPartitionAttributes(FixedPartitionAttributes.createFixedPartition("ODD",
> 1));
> partitionAttributesFactory
>
> .addFixedPartitionAttributes(FixedPartitionAttributes.createFixedPartition("EVEN",
> 1));
> partitionAttributesFactory.setPartitionResolver(new
> EvenOddPartitionResolver());
> partitionAttributesFactory.setRedundantCopies(1);{noformat}
> It appears that it was necessary to create the fixed partitions for the
> custom partition resolver to find.
--
This message was sent by Atlassian JIRA
(v6.4.14#64029)