Java 类com.hazelcast.core.PartitionAware 实例源码

项目:hazelcast-archive    文件:Serializer.java   
public Data writeObject(final Object obj) {
    if (obj == null) {
        return null;
    }
    if (obj instanceof Data) {
        return (Data) obj;
    }
    byte[] bytes = toByteArray(obj);
    if (bytes == null) {
        return null;
    } else {
        Data data = new Data(bytes);
        if (obj instanceof PartitionAware) {
            Data partitionKey = writeObject(((PartitionAware) obj).getPartitionKey());
            int partitionHash = (partitionKey == null) ? -1 : partitionKey.getPartitionHash();
            data.setPartitionHash(partitionHash);
        }
        return data;
    }
}
项目:health-and-care-developer-network    文件:Serializer.java   
public Data writeObject(final Object obj) {
    if (obj == null) {
        return null;
    }
    if (obj instanceof Data) {
        return (Data) obj;
    }
    byte[] bytes = toByteArray(obj);
    if (bytes == null) {
        return null;
    } else {
        Data data = new Data(bytes);
        if (obj instanceof PartitionAware) {
            Data partitionKey = writeObject(((PartitionAware) obj).getPartitionKey());
            int partitionHash = (partitionKey == null) ? -1 : partitionKey.getPartitionHash();
            data.setPartitionHash(partitionHash);
        }
        return data;
    }
}
项目:scheduled-executor    文件:ScheduledExecutorProxy.java   
private <T> int getTaskPartitionId(Callable<T> task) {
    int partitionId;
    if (task instanceof PartitionAware) {
        final Object partitionKey = ((PartitionAware) task).getPartitionKey();
        partitionId = getNodeEngine().getPartitionService().getPartitionId(partitionKey);
    } else {
        partitionId = random.nextInt(partitionCount);
    }
    return partitionId;
}