Search in sources :

Example 6 with Node

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

the class EventDriver method cleanup.

private static void cleanup(Cluster cluster) throws IOException, InterruptedException {
    List<String> args = new ArrayList<String>();
    args.add(scriptDirSuffix);
    Node clientNode = new Node();
    clientNode.setId("client");
    clientNode.setClusterIp(CLUSTER_IP);
    for (Node node : cluster.getNode()) {
        args.add(node.getClusterIp());
    }
    EventUtil.executeLocalScript(clientNode, eventsDir + "/" + "events" + "/" + "cleanup.sh", args);
}
Also used : Node(org.apache.asterix.event.schema.cluster.Node) ArrayList(java.util.ArrayList)

Example 7 with Node

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

the class PatternCreator method getHDFSBackUpAsterixPattern.

private Patterns getHDFSBackUpAsterixPattern(AsterixInstance instance, Backup backupConf) throws Exception {
    Cluster cluster = instance.getCluster();
    String hdfsUrl = backupConf.getHdfs().getUrl();
    String hadoopVersion = backupConf.getHdfs().getVersion();
    String hdfsBackupDir = backupConf.getBackupDir();
    VerificationUtil.verifyBackupRestoreConfiguration(hdfsUrl, hadoopVersion, hdfsBackupDir);
    String workingDir = cluster.getWorkingDir().getDir();
    String backupId = Integer.toString(instance.getBackupInfo().size());
    String store;
    String pargs;
    String iodevices;
    store = cluster.getStore();
    List<Pattern> patternList = new ArrayList<>();
    for (Node node : cluster.getNode()) {
        Nodeid nodeid = new Nodeid(new Value(null, node.getId()));
        iodevices = node.getIodevices() == null ? instance.getCluster().getIodevices() : node.getIodevices();
        pargs = workingDir + " " + instance.getName() + " " + iodevices + " " + store + " " + StorageConstants.METADATA_ROOT + " " + AsterixEventServiceUtil.TXN_LOG_DIR + " " + backupId + " " + hdfsBackupDir + " " + "hdfs" + " " + node.getId() + " " + hdfsUrl + " " + hadoopVersion;
        Event event = new Event("backup", 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 8 with Node

use of org.apache.asterix.event.schema.cluster.Node 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 9 with Node

use of org.apache.asterix.event.schema.cluster.Node 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 10 with Node

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

the class AsterixEventServiceUtil method evaluateConflictWithOtherInstances.

public static void evaluateConflictWithOtherInstances(AsterixInstance instance) throws Exception {
    List<AsterixInstance> existingInstances = ServiceProvider.INSTANCE.getLookupService().getAsterixInstances();
    List<String> usedIps = new ArrayList<String>();
    String masterIp = instance.getCluster().getMasterNode().getClusterIp();
    for (Node node : instance.getCluster().getNode()) {
        usedIps.add(node.getClusterIp());
    }
    usedIps.add(instance.getCluster().getMasterNode().getClusterIp());
    boolean conflictFound = false;
    AsterixInstance conflictingInstance = null;
    for (AsterixInstance existing : existingInstances) {
        if (existing.getState().equals(State.INACTIVE)) {
            continue;
        }
        InetAddress extantAddress = InetAddress.getByName(existing.getCluster().getMasterNode().getClusterIp());
        InetAddress masterAddress = InetAddress.getByName(masterIp);
        if (extantAddress.equals(masterAddress)) {
            conflictingInstance = existing;
            break;
        }
        for (Node n : existing.getCluster().getNode()) {
            if (usedIps.contains(n.getClusterIp())) {
                conflictFound = true;
                conflictingInstance = existing;
                break;
            }
        }
    }
    if (conflictFound) {
        throw new Exception("Cluster definition conflicts with an existing instance of Asterix: " + conflictingInstance.getName());
    }
}
Also used : Node(org.apache.asterix.event.schema.cluster.Node) ArrayList(java.util.ArrayList) AsterixInstance(org.apache.asterix.event.model.AsterixInstance) InetAddress(java.net.InetAddress) EventException(org.apache.asterix.event.error.EventException) IOException(java.io.IOException) JAXBException(javax.xml.bind.JAXBException)

Aggregations

Node (org.apache.asterix.event.schema.cluster.Node)43 ArrayList (java.util.ArrayList)29 Pattern (org.apache.asterix.event.schema.pattern.Pattern)21 Patterns (org.apache.asterix.event.schema.pattern.Patterns)21 Cluster (org.apache.asterix.event.schema.cluster.Cluster)20 Nodeid (org.apache.asterix.event.schema.pattern.Nodeid)16 Value (org.apache.asterix.event.schema.pattern.Value)16 Event (org.apache.asterix.event.schema.pattern.Event)15 File (java.io.File)5 HashSet (java.util.HashSet)5 AsterixInstance (org.apache.asterix.event.model.AsterixInstance)5 FileOutputStream (java.io.FileOutputStream)3 JAXBContext (javax.xml.bind.JAXBContext)3 Marshaller (javax.xml.bind.Marshaller)3 AsterixEventServiceClient (org.apache.asterix.event.management.AsterixEventServiceClient)3 AsterixRuntimeState (org.apache.asterix.event.model.AsterixRuntimeState)3 ProcessInfo (org.apache.asterix.event.model.ProcessInfo)3 Date (java.util.Date)2 IClusterManagementWork (org.apache.asterix.common.api.IClusterManagementWork)2 AsterixException (org.apache.asterix.common.exceptions.AsterixException)2