use of org.apache.asterix.metadata.entities.NodeGroup in project asterixdb by apache.
the class MetadataManagerUtil method findNodeDomain.
public static INodeDomain findNodeDomain(MetadataTransactionContext mdTxnCtx, String nodeGroupName) throws AlgebricksException {
NodeGroup nodeGroup = MetadataManager.INSTANCE.getNodegroup(mdTxnCtx, nodeGroupName);
List<String> partitions = new ArrayList<>();
for (String location : nodeGroup.getNodeNames()) {
int numPartitions = ClusterStateManager.INSTANCE.getNodePartitionsCount(location);
for (int i = 0; i < numPartitions; i++) {
partitions.add(location);
}
}
return new DefaultNodeGroupDomain(partitions);
}
use of org.apache.asterix.metadata.entities.NodeGroup in project asterixdb by apache.
the class MetadataNode method getNodeGroup.
@Override
public NodeGroup getNodeGroup(JobId jobId, String nodeGroupName) throws MetadataException, RemoteException {
try {
ITupleReference searchKey = createTuple(nodeGroupName);
NodeGroupTupleTranslator tupleReaderWriter = tupleTranslatorProvider.getNodeGroupTupleTranslator(false);
IValueExtractor<NodeGroup> valueExtractor = new MetadataEntityValueExtractor<>(tupleReaderWriter);
List<NodeGroup> results = new ArrayList<>();
searchIndex(jobId, MetadataPrimaryIndexes.NODEGROUP_DATASET, searchKey, valueExtractor, results);
if (results.isEmpty()) {
return null;
}
return results.get(0);
} catch (HyracksDataException e) {
throw new MetadataException(e);
}
}
use of org.apache.asterix.metadata.entities.NodeGroup in project asterixdb by apache.
the class MetadataTransactionContext method dropNodeGroup.
public void dropNodeGroup(String nodeGroupName) {
NodeGroup nodeGroup = new NodeGroup(nodeGroupName, null);
droppedCache.addNodeGroupIfNotExists(nodeGroup);
logAndApply(new MetadataLogicalOperation(nodeGroup, false));
}
use of org.apache.asterix.metadata.entities.NodeGroup in project asterixdb by apache.
the class NodeGroupTupleTranslator method getMetadataEntityFromTuple.
@Override
public NodeGroup getMetadataEntityFromTuple(ITupleReference frameTuple) throws HyracksDataException {
byte[] serRecord = frameTuple.getFieldData(NODEGROUP_PAYLOAD_TUPLE_FIELD_INDEX);
int recordStartOffset = frameTuple.getFieldStart(NODEGROUP_PAYLOAD_TUPLE_FIELD_INDEX);
int recordLength = frameTuple.getFieldLength(NODEGROUP_PAYLOAD_TUPLE_FIELD_INDEX);
ByteArrayInputStream stream = new ByteArrayInputStream(serRecord, recordStartOffset, recordLength);
DataInput in = new DataInputStream(stream);
ARecord nodeGroupRecord = recordSerDes.deserialize(in);
String gpName = ((AString) nodeGroupRecord.getValueByPos(MetadataRecordTypes.NODEGROUP_ARECORD_GROUPNAME_FIELD_INDEX)).getStringValue();
IACursor cursor = ((AUnorderedList) nodeGroupRecord.getValueByPos(MetadataRecordTypes.NODEGROUP_ARECORD_NODENAMES_FIELD_INDEX)).getCursor();
List<String> nodeNames = new ArrayList<>();
while (cursor.next()) {
nodeNames.add(((AString) cursor.get()).getStringValue());
}
return new NodeGroup(gpName, nodeNames);
}
Aggregations