use of org.apache.asterix.event.schema.pattern.Patterns in project asterixdb by apache.
the class RestoreConfig method execCommand.
@Override
protected void execCommand() throws Exception {
InstallerDriver.initConfig(true);
String asterixInstanceName = ((RestoreConfig) config).name;
AsterixInstance instance = AsterixEventServiceUtil.validateAsterixInstanceExists(asterixInstanceName, State.INACTIVE);
int backupId = ((RestoreConfig) config).backupId;
List<BackupInfo> backupInfoList = instance.getBackupInfo();
if (backupInfoList.size() <= backupId || backupId < 0) {
throw new IllegalStateException("Invalid backup id");
}
BackupInfo backupInfo = backupInfoList.get(backupId);
Patterns patterns = PatternCreator.INSTANCE.getRestoreAsterixPattern(instance, backupInfo);
AsterixEventService.getAsterixEventServiceClient(instance.getCluster()).submit(patterns);
LOGGER.info("Asterix instance: " + asterixInstanceName + " has been restored from backup");
}
use of org.apache.asterix.event.schema.pattern.Patterns in project asterixdb by apache.
the class StartConfig method execCommand.
@Override
protected void execCommand() throws Exception {
InstallerDriver.initConfig(true);
String asterixInstanceName = ((StartConfig) config).name;
AsterixInstance instance = AsterixEventServiceUtil.validateAsterixInstanceExists(asterixInstanceName, State.INACTIVE);
AsterixEventServiceUtil.createAsterixZip(instance);
AsterixEventServiceClient client = AsterixEventService.getAsterixEventServiceClient(instance.getCluster());
Patterns asterixBinaryTransferPattern = PatternCreator.INSTANCE.getAsterixBinaryTransferPattern(asterixInstanceName, instance.getCluster());
client.submit(asterixBinaryTransferPattern);
// Start the watcher
ClusterStateWatcher stateWatcher = ServiceProvider.INSTANCE.getLookupService().startWatchingClusterState(asterixInstanceName);
AsterixEventServiceUtil.createClusterProperties(instance.getCluster(), instance.getAsterixConfiguration());
Patterns patterns = PatternCreator.INSTANCE.getStartAsterixPattern(asterixInstanceName, instance.getCluster(), false);
client.submit(patterns);
// Check the cluster state
ClusterState clusterState = stateWatcher.waitForClusterStart();
if (clusterState != ClusterState.ACTIVE) {
throw new Exception("CC failed to start");
}
AsterixEventServiceUtil.deleteDirectory(InstallerDriver.getManagixHome() + File.separator + InstallerDriver.ASTERIX_DIR + File.separator + asterixInstanceName);
AsterixRuntimeState runtimeState = VerificationUtil.getAsterixRuntimeState(instance);
VerificationUtil.updateInstanceWithRuntimeDescription(instance, runtimeState, true);
LOGGER.info(instance.getDescription(false));
ServiceProvider.INSTANCE.getLookupService().updateAsterixInstance(instance);
}
use of org.apache.asterix.event.schema.pattern.Patterns in project asterixdb by apache.
the class AsterixEventServiceClient method initializeCluster.
private void initializeCluster(String eventsDir) throws Exception {
Patterns patterns = initPattern(eventsDir);
submit(patterns);
}
use of org.apache.asterix.event.schema.pattern.Patterns 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);
}
use of org.apache.asterix.event.schema.pattern.Patterns 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);
}
Aggregations