use of org.apache.asterix.event.schema.pattern.Patterns 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);
}
use of org.apache.asterix.event.schema.pattern.Patterns 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);
}
use of org.apache.asterix.event.schema.pattern.Patterns in project asterixdb by apache.
the class PatternCreator method getGenerateLogPattern.
public Patterns getGenerateLogPattern(Cluster cluster, String outputDir) {
List<Pattern> patternList = new ArrayList<>();
Map<String, String> nodeLogs = new HashMap<>();
String username = cluster.getUsername() == null ? System.getProperty("user.name") : cluster.getUsername();
String srcHost = cluster.getMasterNode().getClientIp();
Nodeid nodeid = new Nodeid(new Value(null, EventDriver.CLIENT_NODE.getId()));
String srcDir = cluster.getMasterNode().getLogDir() == null ? cluster.getLogDir() : cluster.getMasterNode().getLogDir();
String destDir = outputDir + File.separator + "cc";
String pargs = username + " " + srcHost + " " + srcDir + " " + destDir;
Event event = new Event("directory_copy", nodeid, pargs);
Pattern p = new Pattern(null, 1, null, event);
patternList.add(p);
nodeLogs.put(cluster.getMasterNode().getClusterIp(), srcDir);
for (Node node : cluster.getNode()) {
srcHost = node.getClusterIp();
srcDir = node.getLogDir() == null ? cluster.getLogDir() : node.getLogDir();
if (nodeLogs.get(node.getClusterIp()) != null && nodeLogs.get(node.getClusterIp()).equals(srcDir)) {
continue;
}
destDir = outputDir + File.separator + node.getId();
pargs = username + " " + srcHost + " " + srcDir + " " + destDir;
event = new Event("directory_copy", nodeid, pargs);
p = new Pattern(null, 1, null, event);
patternList.add(p);
}
return new Patterns(patternList);
}
use of org.apache.asterix.event.schema.pattern.Patterns in project asterixdb by apache.
the class BackupConfig method execCommand.
@Override
protected void execCommand() throws Exception {
InstallerDriver.initConfig(true);
String asterixInstanceName = ((BackupConfig) config).name;
AsterixInstance instance = AsterixEventServiceUtil.validateAsterixInstanceExists(asterixInstanceName, State.INACTIVE);
List<BackupInfo> backupInfo = instance.getBackupInfo();
Backup backupConf = AsterixEventService.getConfiguration().getBackup();
Patterns patterns = PatternCreator.INSTANCE.getBackUpAsterixPattern(instance, backupConf);
AsterixEventService.getAsterixEventServiceClient(instance.getCluster()).submit(patterns);
int backupId = backupInfo.size();
BackupInfo binfo = new BackupInfo(backupId, new Date(), backupConf);
backupInfo.add(binfo);
LOGGER.info(asterixInstanceName + " backed up " + binfo);
ServiceProvider.INSTANCE.getLookupService().updateAsterixInstance(instance);
}
use of org.apache.asterix.event.schema.pattern.Patterns in project asterixdb by apache.
the class CreateConfig method execCommand.
@Override
protected void execCommand() throws Exception {
InstallerDriver.initConfig(true);
ValidateCommand validateCommand = new ValidateCommand();
boolean valid = validateCommand.validateCluster(((CreateConfig) config).clusterPath);
if (!valid) {
throw new Exception("Cannot create an Asterix instance.");
}
asterixInstanceName = ((CreateConfig) config).name;
AsterixEventServiceUtil.validateAsterixInstanceNotExists(asterixInstanceName);
CreateConfig createConfig = (CreateConfig) config;
cluster = EventUtil.getCluster(createConfig.clusterPath);
cluster.setInstanceName(asterixInstanceName);
asterixConfiguration = InstallerUtil.getAsterixConfiguration(createConfig.asterixConfPath);
AsterixInstance asterixInstance = AsterixEventServiceUtil.createAsterixInstance(asterixInstanceName, cluster, asterixConfiguration);
AsterixEventServiceUtil.evaluateConflictWithOtherInstances(asterixInstance);
AsterixEventServiceUtil.createAsterixZip(asterixInstance);
AsterixEventServiceUtil.createClusterProperties(cluster, asterixConfiguration);
AsterixEventServiceClient eventrixClient = AsterixEventService.getAsterixEventServiceClient(cluster, true, false);
// Store the cluster initially in Zookeeper and start watching
ServiceProvider.INSTANCE.getLookupService().writeAsterixInstance(asterixInstance);
ClusterStateWatcher stateWatcher = ServiceProvider.INSTANCE.getLookupService().startWatchingClusterState(asterixInstanceName);
Patterns asterixBinarytrasnferPattern = PatternCreator.INSTANCE.getAsterixBinaryTransferPattern(asterixInstanceName, cluster);
eventrixClient.submit(asterixBinarytrasnferPattern);
Patterns patterns = PatternCreator.INSTANCE.getStartAsterixPattern(asterixInstanceName, cluster, true);
eventrixClient.submit(patterns);
// Check the cluster state
ClusterState clusterState = stateWatcher.waitForClusterStart();
if (clusterState != ClusterState.ACTIVE) {
throw new Exception("CC failed to start");
}
AsterixRuntimeState runtimeState = VerificationUtil.getAsterixRuntimeState(asterixInstance);
VerificationUtil.updateInstanceWithRuntimeDescription(asterixInstance, runtimeState, true);
ServiceProvider.INSTANCE.getLookupService().updateAsterixInstance(asterixInstance);
AsterixEventServiceUtil.deleteDirectory(InstallerDriver.getManagixHome() + File.separator + InstallerDriver.ASTERIX_DIR + File.separator + asterixInstanceName);
LOGGER.info(asterixInstance.getDescription(false));
}
Aggregations