use of com.tencent.angel.ps.storage.partition.IServerPartition in project angel by Tencent.
the class ServerMatrix method init.
public void init() {
MatrixMeta matrixMeta = context.getMatrixMetaManager().getMatrixMeta(matrixId);
Map<Integer, PartitionMeta> partMetas = matrixMeta.getPartitionMetas();
String sourceClass = matrixMeta.getAttribute(AngelConf.ANGEL_PS_PARTITION_SOURCE_CLASS, AngelConf.DEFAULT_ANGEL_PS_PARTITION_SOURCE_CLASS);
// Get server partition class
Class<? extends IServerPartition> partClass;
try {
partClass = matrixMeta.getPartitionClass();
// If partition class is not set, just use the default partition class
if (partClass == null) {
partClass = MatrixConf.DEFAULT_SERVER_PARTITION_CLASS;
}
} catch (Throwable e) {
LOG.fatal("Server partition class failed ", e);
throw new RuntimeException(e);
}
// Get server partition storage class type
Class<? extends IServerPartitionStorage> storageClass;
try {
storageClass = matrixMeta.getPartitionStorageClass();
} catch (Throwable e) {
LOG.fatal("Server partition class failed ", e);
throw new RuntimeException(e);
}
RowType rowType = matrixMeta.getRowType();
// Get value class
Class<? extends IElement> valueClass = null;
if (rowType.isComplexValue()) {
try {
valueClass = matrixMeta.getValueClass();
} catch (Throwable e) {
LOG.fatal("Init value class failed ", e);
throw new RuntimeException(e);
}
if (valueClass == null) {
throw new RuntimeException("Complex type must set value type class!!");
}
}
for (PartitionMeta partMeta : partMetas.values()) {
ServerPartition part = ServerPartitionFactory.getPartition(partMeta.getPartitionKey(), partClass, storageClass, matrixMeta.getRowType(), valueClass, matrixMeta.getValidIndexNumInOnePart(), matrixMeta.isHash() ? RouterType.HASH : RouterType.RANGE);
partitionMaps.put(partMeta.getPartId(), part);
part.init();
part.setState(PartitionState.READ_AND_WRITE);
}
}
Aggregations