Search in sources :

Example 21 with Pattern

use of org.apache.asterix.event.schema.pattern.Pattern in project asterixdb by apache.

the class PatternCreator method createNCStartPattern.

public Pattern createNCStartPattern(String ccHost, String hostId, String nodeControllerId, String iodevices, boolean isInitialRun) {
    Nodeid nodeid = new Nodeid(new Value(null, hostId));
    String pargs = ccHost + " " + nodeControllerId + " " + iodevices;
    if (isInitialRun) {
        pargs += " " + "-initial-run";
    }
    Event event = new Event("node_join", nodeid, pargs);
    return new Pattern(null, 1, null, event);
}
Also used : Pattern(org.apache.asterix.event.schema.pattern.Pattern) Nodeid(org.apache.asterix.event.schema.pattern.Nodeid) Value(org.apache.asterix.event.schema.pattern.Value) Event(org.apache.asterix.event.schema.pattern.Event)

Example 22 with Pattern

use of org.apache.asterix.event.schema.pattern.Pattern in project asterixdb by apache.

the class PatternCreator method getLibraryUninstallPattern.

public Patterns getLibraryUninstallPattern(AsterixInstance instance, String dataverse, String libraryName) throws Exception {
    List<Pattern> patternList = new ArrayList<>();
    Cluster cluster = instance.getCluster();
    String workingDir = cluster.getWorkingDir().getDir();
    String destFile = dataverse + "." + libraryName;
    String pargs = workingDir + File.separator + "uninstall" + " " + destFile;
    String metadataNodeId = instance.getMetadataNodeId();
    Nodeid nodeid = new Nodeid(new Value(null, metadataNodeId));
    Event event = new Event("file_create", nodeid, pargs);
    Pattern p = new Pattern(null, 1, null, event);
    patternList.add(p);
    Iterator<Node> uninstallTargets = cluster.getNode().iterator();
    String libDir = workingDir + File.separator + "library" + File.separator + dataverse + File.separator + libraryName;
    Node uninstallNode = uninstallTargets.next();
    nodeid = new Nodeid(new Value(null, uninstallNode.getId()));
    event = new Event("file_delete", nodeid, libDir);
    p = new Pattern(null, 1, null, event);
    patternList.add(p);
    pargs = libDir;
    if (!cluster.getWorkingDir().isNFS()) {
        while (uninstallTargets.hasNext()) {
            uninstallNode = uninstallTargets.next();
            nodeid = new Nodeid(new Value(null, uninstallNode.getId()));
            event = new Event("file_delete", nodeid, pargs);
            p = new Pattern(null, 1, null, event);
            patternList.add(p);
        }
        nodeid = new Nodeid(new Value(null, cluster.getMasterNode().getId()));
        event = new Event("file_delete", 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) Patterns(org.apache.asterix.event.schema.pattern.Patterns)

Example 23 with Pattern

use of org.apache.asterix.event.schema.pattern.Pattern in project asterixdb by apache.

the class PatternCreator method createRemoveHDFSBackupPattern.

private Patterns createRemoveHDFSBackupPattern(AsterixInstance instance, String hdfsBackupDir) throws Exception {
    List<Pattern> patternList = new ArrayList<>();
    Cluster cluster = instance.getCluster();
    String hdfsUrl = AsterixEventService.getConfiguration().getBackup().getHdfs().getUrl();
    String hadoopVersion = AsterixEventService.getConfiguration().getBackup().getHdfs().getVersion();
    String workingDir = cluster.getWorkingDir().getDir();
    Node launchingNode = cluster.getNode().get(0);
    Nodeid nodeid = new Nodeid(new Value(null, launchingNode.getId()));
    String pathToDelete = hdfsBackupDir + File.separator + instance.getName();
    String pargs = workingDir + " " + hadoopVersion + " " + hdfsUrl + " " + pathToDelete;
    Event event = new Event("hdfs_delete", 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 24 with Pattern

use of org.apache.asterix.event.schema.pattern.Pattern in project asterixdb by apache.

the class PatternCreator method createDeleteInstancePattern.

public Patterns createDeleteInstancePattern(AsterixInstance instance) throws Exception {
    List<Pattern> patternList = new ArrayList<>();
    patternList.addAll(createRemoveAsterixStoragePattern(instance).getPattern());
    if (instance.getBackupInfo() != null && !instance.getBackupInfo().isEmpty()) {
        List<BackupInfo> backups = instance.getBackupInfo();
        Set<String> removedBackupDirsHDFS = new HashSet<>();
        Set<String> removedBackupDirsLocal = new HashSet<>();
        String backupDir;
        for (BackupInfo binfo : backups) {
            backupDir = binfo.getBackupConf().getBackupDir();
            switch(binfo.getBackupType()) {
                case HDFS:
                    if (removedBackupDirsHDFS.contains(backupDir)) {
                        continue;
                    }
                    patternList.addAll(createRemoveHDFSBackupPattern(instance, backupDir).getPattern());
                    removedBackupDirsHDFS.add(backupDir);
                    break;
                case LOCAL:
                    if (removedBackupDirsLocal.contains(backupDir)) {
                        continue;
                    }
                    patternList.addAll(createRemoveLocalBackupPattern(instance, backupDir).getPattern());
                    removedBackupDirsLocal.add(backupDir);
                    break;
            }
        }
    }
    patternList.addAll(createRemoveAsterixLogDirPattern(instance).getPattern());
    patternList.addAll(createRemoveAsterixRootMetadata(instance).getPattern());
    patternList.addAll(createRemoveAsterixTxnLogs(instance).getPattern());
    return new Patterns(patternList);
}
Also used : BackupInfo(org.apache.asterix.event.model.BackupInfo) Pattern(org.apache.asterix.event.schema.pattern.Pattern) ArrayList(java.util.ArrayList) Patterns(org.apache.asterix.event.schema.pattern.Patterns) HashSet(java.util.HashSet)

Example 25 with Pattern

use of org.apache.asterix.event.schema.pattern.Pattern in project asterixdb by apache.

the class PatternCreator method createRemoveAsterixRootMetadata.

private Patterns createRemoveAsterixRootMetadata(AsterixInstance instance) throws Exception {
    List<Pattern> patternList = new ArrayList<>();
    Cluster cluster = instance.getCluster();
    Nodeid nodeid;
    String pargs;
    Event event;
    for (Node node : cluster.getNode()) {
        String iodevices = node.getIodevices() == null ? cluster.getIodevices() : node.getIodevices();
        String primaryIODevice = iodevices.split(",")[0].trim();
        pargs = primaryIODevice + File.separator + StorageConstants.METADATA_ROOT;
        nodeid = new Nodeid(new Value(null, node.getId()));
        event = new Event("file_delete", 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)

Aggregations

Pattern (org.apache.asterix.event.schema.pattern.Pattern)32 ArrayList (java.util.ArrayList)24 Patterns (org.apache.asterix.event.schema.pattern.Patterns)24 Event (org.apache.asterix.event.schema.pattern.Event)23 Nodeid (org.apache.asterix.event.schema.pattern.Nodeid)22 Value (org.apache.asterix.event.schema.pattern.Value)22 Node (org.apache.asterix.event.schema.cluster.Node)21 Cluster (org.apache.asterix.event.schema.cluster.Cluster)15 File (java.io.File)5 AsterixInstance (org.apache.asterix.event.model.AsterixInstance)4 AsterixEventServiceClient (org.apache.asterix.event.management.AsterixEventServiceClient)3 Date (java.util.Date)2 AsterixRuntimeState (org.apache.asterix.event.model.AsterixRuntimeState)2 ProcessInfo (org.apache.asterix.event.model.ProcessInfo)2 InstallerException (org.apache.asterix.installer.error.InstallerException)2 FileOutputStream (java.io.FileOutputStream)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 JAXBContext (javax.xml.bind.JAXBContext)1 Marshaller (javax.xml.bind.Marshaller)1