Search in sources :

Example 11 with Cluster

use of org.apache.asterix.event.schema.cluster.Cluster in project asterixdb by apache.

the class PatternCreator method getHDFSRestoreAsterixPattern.

public Patterns getHDFSRestoreAsterixPattern(AsterixInstance instance, BackupInfo backupInfo) throws Exception {
    Cluster cluster = instance.getCluster();
    String clusterStore = instance.getCluster().getStore();
    String hdfsUrl = backupInfo.getBackupConf().getHdfs().getUrl();
    String hadoopVersion = backupInfo.getBackupConf().getHdfs().getVersion();
    String hdfsBackupDir = backupInfo.getBackupConf().getBackupDir();
    VerificationUtil.verifyBackupRestoreConfiguration(hdfsUrl, hadoopVersion, hdfsBackupDir);
    String workingDir = cluster.getWorkingDir().getDir();
    int backupId = backupInfo.getId();
    String pargs;
    List<Pattern> patternList = new ArrayList<>();
    for (Node node : cluster.getNode()) {
        Nodeid nodeid = new Nodeid(new Value(null, node.getId()));
        String iodevices = node.getIodevices() == null ? cluster.getIodevices() : node.getIodevices();
        pargs = workingDir + " " + instance.getName() + " " + iodevices + " " + clusterStore + " " + StorageConstants.METADATA_ROOT + " " + AsterixEventServiceUtil.TXN_LOG_DIR + " " + backupId + " " + " " + hdfsBackupDir + " " + "hdfs" + " " + node.getId() + " " + hdfsUrl + " " + hadoopVersion;
        Event event = new Event("restore", nodeid, pargs);
        patternList.add(new Pattern(null, 1, null, event));
    }
    return new Patterns(patternList);
}
Also used : Pattern(org.apache.asterix.event.schema.pattern.Pattern) Node(org.apache.asterix.event.schema.cluster.Node) ArrayList(java.util.ArrayList) Nodeid(org.apache.asterix.event.schema.pattern.Nodeid) Value(org.apache.asterix.event.schema.pattern.Value) Cluster(org.apache.asterix.event.schema.cluster.Cluster) Event(org.apache.asterix.event.schema.pattern.Event) Patterns(org.apache.asterix.event.schema.pattern.Patterns)

Example 12 with Cluster

use of org.apache.asterix.event.schema.cluster.Cluster in project asterixdb by apache.

the class PatternCreator method getLocalRestoreAsterixPattern.

public Patterns getLocalRestoreAsterixPattern(AsterixInstance instance, BackupInfo backupInfo) throws Exception {
    Cluster cluster = instance.getCluster();
    String clusterStore = instance.getCluster().getStore();
    String backupDir = backupInfo.getBackupConf().getBackupDir();
    String workingDir = cluster.getWorkingDir().getDir();
    int backupId = backupInfo.getId();
    String pargs;
    List<Pattern> patternList = new ArrayList<>();
    for (Node node : cluster.getNode()) {
        Nodeid nodeid = new Nodeid(new Value(null, node.getId()));
        String iodevices = node.getIodevices() == null ? cluster.getIodevices() : node.getIodevices();
        pargs = workingDir + " " + instance.getName() + " " + iodevices + " " + clusterStore + " " + StorageConstants.METADATA_ROOT + " " + AsterixEventServiceUtil.TXN_LOG_DIR + " " + backupId + " " + backupDir + " " + "local" + " " + node.getId();
        Event event = new Event("restore", nodeid, pargs);
        patternList.add(new Pattern(null, 1, null, event));
    }
    return new Patterns(patternList);
}
Also used : Pattern(org.apache.asterix.event.schema.pattern.Pattern) Node(org.apache.asterix.event.schema.cluster.Node) ArrayList(java.util.ArrayList) Nodeid(org.apache.asterix.event.schema.pattern.Nodeid) Value(org.apache.asterix.event.schema.pattern.Value) Cluster(org.apache.asterix.event.schema.cluster.Cluster) Event(org.apache.asterix.event.schema.pattern.Event) Patterns(org.apache.asterix.event.schema.pattern.Patterns)

Example 13 with Cluster

use of org.apache.asterix.event.schema.cluster.Cluster in project asterixdb by apache.

the class PatternCreator method createRemoveAsterixTxnLogs.

private Patterns createRemoveAsterixTxnLogs(AsterixInstance instance) throws Exception {
    List<Pattern> patternList = new ArrayList<>();
    Cluster cluster = instance.getCluster();
    Nodeid nodeid;
    Event event;
    for (Node node : cluster.getNode()) {
        String txnLogDir = node.getTxnLogDir() == null ? cluster.getTxnLogDir() : node.getTxnLogDir();
        nodeid = new Nodeid(new Value(null, node.getId()));
        event = new Event("file_delete", nodeid, txnLogDir);
        patternList.add(new Pattern(null, 1, null, event));
    }
    return new Patterns(patternList);
}
Also used : Pattern(org.apache.asterix.event.schema.pattern.Pattern) Node(org.apache.asterix.event.schema.cluster.Node) ArrayList(java.util.ArrayList) Nodeid(org.apache.asterix.event.schema.pattern.Nodeid) Value(org.apache.asterix.event.schema.pattern.Value) Cluster(org.apache.asterix.event.schema.cluster.Cluster) Event(org.apache.asterix.event.schema.pattern.Event) Patterns(org.apache.asterix.event.schema.pattern.Patterns)

Example 14 with Cluster

use of org.apache.asterix.event.schema.cluster.Cluster in project asterixdb by apache.

the class PatternCreator method getLibraryInstallPattern.

public Patterns getLibraryInstallPattern(AsterixInstance instance, String dataverse, String libraryName, String libraryPath) throws Exception {
    List<Pattern> patternList = new ArrayList<>();
    Cluster cluster = instance.getCluster();
    Nodeid nodeid = new Nodeid(new Value(null, EventDriver.CLIENT_NODE.getId()));
    String username = cluster.getUsername() != null ? cluster.getUsername() : System.getProperty("user.name");
    String workingDir = cluster.getWorkingDir().getDir();
    String destDir = workingDir + File.separator + "library" + File.separator + dataverse + File.separator + libraryName;
    String fileToTransfer = new File(libraryPath).getAbsolutePath();
    Iterator<Node> installTargets = cluster.getNode().iterator();
    Node installNode = installTargets.next();
    String destinationIp = installNode.getClusterIp();
    String pargs = username + " " + fileToTransfer + " " + destinationIp + " " + destDir + " " + "unpack";
    Event event = new Event("file_transfer", nodeid, pargs);
    Pattern p = new Pattern(null, 1, null, event);
    patternList.add(p);
    if (!cluster.getWorkingDir().isNFS()) {
        while (installTargets.hasNext()) {
            Node node = installTargets.next();
            pargs = username + " " + fileToTransfer + " " + node.getClusterIp() + " " + destDir + " " + "unpack";
            event = new Event("file_transfer", nodeid, pargs);
            p = new Pattern(null, 1, null, event);
            patternList.add(p);
        }
        pargs = username + " " + fileToTransfer + " " + cluster.getMasterNode().getClusterIp() + " " + destDir + " " + "unpack";
        event = new Event("file_transfer", nodeid, pargs);
        p = new Pattern(null, 1, null, event);
        patternList.add(p);
    }
    return new Patterns(patternList);
}
Also used : Pattern(org.apache.asterix.event.schema.pattern.Pattern) Node(org.apache.asterix.event.schema.cluster.Node) ArrayList(java.util.ArrayList) Nodeid(org.apache.asterix.event.schema.pattern.Nodeid) Value(org.apache.asterix.event.schema.pattern.Value) Cluster(org.apache.asterix.event.schema.cluster.Cluster) Event(org.apache.asterix.event.schema.pattern.Event) File(java.io.File) Patterns(org.apache.asterix.event.schema.pattern.Patterns)

Example 15 with Cluster

use of org.apache.asterix.event.schema.cluster.Cluster in project asterixdb by apache.

the class NCApplication method updateOnNodeJoin.

private void updateOnNodeJoin() {
    MetadataProperties metadataProperties = runtimeContext.getMetadataProperties();
    if (!metadataProperties.getNodeNames().contains(nodeId)) {
        Cluster cluster = ClusterProperties.INSTANCE.getCluster();
        if (cluster == null) {
            throw new IllegalStateException("No cluster configuration found for this instance");
        }
        NCConfig ncConfig = ((NodeControllerService) ncServiceCtx.getControllerService()).getConfiguration();
        ncConfig.getConfigManager().registerVirtualNode(nodeId);
        String asterixInstanceName = metadataProperties.getInstanceName();
        TransactionProperties txnProperties = runtimeContext.getTransactionProperties();
        Node self = null;
        List<Node> nodes;
        if (cluster.getSubstituteNodes() != null) {
            nodes = cluster.getSubstituteNodes().getNode();
        } else {
            throw new IllegalStateException("Unknown node joining the cluster");
        }
        for (Node node : nodes) {
            String ncId = asterixInstanceName + "_" + node.getId();
            if (ncId.equalsIgnoreCase(nodeId)) {
                String storeDir = ClusterProperties.INSTANCE.getStorageDirectoryName();
                String nodeIoDevices = node.getIodevices() == null ? cluster.getIodevices() : node.getIodevices();
                String[] ioDevicePaths = nodeIoDevices.trim().split(",");
                for (int i = 0; i < ioDevicePaths.length; i++) {
                    // construct full store path
                    ioDevicePaths[i] += File.separator + storeDir;
                }
                metadataProperties.getStores().put(nodeId, ioDevicePaths);
                String coredumpPath = node.getLogDir() == null ? cluster.getLogDir() : node.getLogDir();
                metadataProperties.getCoredumpPaths().put(nodeId, coredumpPath);
                String txnLogDir = node.getTxnLogDir() == null ? cluster.getTxnLogDir() : node.getTxnLogDir();
                txnProperties.getLogDirectories().put(nodeId, txnLogDir);
                if (LOGGER.isLoggable(Level.INFO)) {
                    LOGGER.info("Store set to : " + storeDir);
                    LOGGER.info("Coredump dir set to : " + coredumpPath);
                    LOGGER.info("Transaction log dir set to :" + txnLogDir);
                }
                self = node;
                break;
            }
        }
        if (self != null) {
            cluster.getSubstituteNodes().getNode().remove(self);
            cluster.getNode().add(self);
        } else {
            throw new IllegalStateException("Unknown node joining the cluster");
        }
    }
}
Also used : NodeControllerService(org.apache.hyracks.control.nc.NodeControllerService) NCConfig(org.apache.hyracks.control.common.controllers.NCConfig) TransactionProperties(org.apache.asterix.common.config.TransactionProperties) Node(org.apache.asterix.event.schema.cluster.Node) Cluster(org.apache.asterix.event.schema.cluster.Cluster) MetadataProperties(org.apache.asterix.common.config.MetadataProperties)

Aggregations

Cluster (org.apache.asterix.event.schema.cluster.Cluster)31 ArrayList (java.util.ArrayList)22 Node (org.apache.asterix.event.schema.cluster.Node)20 Pattern (org.apache.asterix.event.schema.pattern.Pattern)15 Patterns (org.apache.asterix.event.schema.pattern.Patterns)15 Event (org.apache.asterix.event.schema.pattern.Event)13 Nodeid (org.apache.asterix.event.schema.pattern.Nodeid)13 Value (org.apache.asterix.event.schema.pattern.Value)13 File (java.io.File)8 JAXBContext (javax.xml.bind.JAXBContext)8 HashSet (java.util.HashSet)6 Unmarshaller (javax.xml.bind.Unmarshaller)5 List (java.util.List)4 ParallelActionSet (org.apache.asterix.experiment.action.base.ParallelActionSet)4 SequentialActionList (org.apache.asterix.experiment.action.base.SequentialActionList)4 LogAsterixManagixAction (org.apache.asterix.experiment.action.derived.ManagixActions.LogAsterixManagixAction)4 StopAsterixManagixAction (org.apache.asterix.experiment.action.derived.ManagixActions.StopAsterixManagixAction)4 FileOutputStream (java.io.FileOutputStream)3 Marshaller (javax.xml.bind.Marshaller)3 AbstractRemoteExecutableAction (org.apache.asterix.experiment.action.derived.AbstractRemoteExecutableAction)3