Search in sources :

Example 6 with NodeGroup

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);
}
Also used : ArrayList(java.util.ArrayList) DefaultNodeGroupDomain(org.apache.hyracks.algebricks.core.algebra.properties.DefaultNodeGroupDomain) NodeGroup(org.apache.asterix.metadata.entities.NodeGroup)

Example 7 with NodeGroup

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);
    }
}
Also used : MetadataEntityValueExtractor(org.apache.asterix.metadata.valueextractors.MetadataEntityValueExtractor) NodeGroupTupleTranslator(org.apache.asterix.metadata.entitytupletranslators.NodeGroupTupleTranslator) ITupleReference(org.apache.hyracks.dataflow.common.data.accessors.ITupleReference) ArrayList(java.util.ArrayList) HyracksDataException(org.apache.hyracks.api.exceptions.HyracksDataException) NodeGroup(org.apache.asterix.metadata.entities.NodeGroup)

Example 8 with NodeGroup

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));
}
Also used : NodeGroup(org.apache.asterix.metadata.entities.NodeGroup)

Example 9 with NodeGroup

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);
}
Also used : ArrayList(java.util.ArrayList) AUnorderedList(org.apache.asterix.om.base.AUnorderedList) AString(org.apache.asterix.om.base.AString) IACursor(org.apache.asterix.om.base.IACursor) DataInputStream(java.io.DataInputStream) DataInput(java.io.DataInput) ARecord(org.apache.asterix.om.base.ARecord) ByteArrayInputStream(java.io.ByteArrayInputStream) AString(org.apache.asterix.om.base.AString) NodeGroup(org.apache.asterix.metadata.entities.NodeGroup)

Aggregations

NodeGroup (org.apache.asterix.metadata.entities.NodeGroup)9 ArrayList (java.util.ArrayList)6 RemoteException (java.rmi.RemoteException)3 MetadataTransactionContext (org.apache.asterix.metadata.MetadataTransactionContext)3 HyracksDataException (org.apache.hyracks.api.exceptions.HyracksDataException)3 IOException (java.io.IOException)2 ACIDException (org.apache.asterix.common.exceptions.ACIDException)2 AsterixException (org.apache.asterix.common.exceptions.AsterixException)2 CompilationException (org.apache.asterix.common.exceptions.CompilationException)2 MetadataException (org.apache.asterix.metadata.MetadataException)2 AString (org.apache.asterix.om.base.AString)2 AlgebricksException (org.apache.hyracks.algebricks.common.exceptions.AlgebricksException)2 ByteArrayInputStream (java.io.ByteArrayInputStream)1 DataInput (java.io.DataInput)1 DataInputStream (java.io.DataInputStream)1 NodeGroupDropStatement (org.apache.asterix.lang.common.statement.NodeGroupDropStatement)1 NodegroupDecl (org.apache.asterix.lang.common.statement.NodegroupDecl)1 Identifier (org.apache.asterix.lang.common.struct.Identifier)1 NodeGroupTupleTranslator (org.apache.asterix.metadata.entitytupletranslators.NodeGroupTupleTranslator)1 MetadataEntityValueExtractor (org.apache.asterix.metadata.valueextractors.MetadataEntityValueExtractor)1