Search in sources :

Example 1 with PatternCreator

use of org.apache.asterix.event.util.PatternCreator in project asterixdb by apache.

the class InstallConfig method execCommand.

@Override
protected void execCommand() throws Exception {
    InstallerDriver.initConfig(true);
    InstallConfig installConfig = ((InstallConfig) config);
    String instanceName = installConfig.name;
    AsterixInstance instance = AsterixEventServiceUtil.validateAsterixInstanceExists(instanceName, State.INACTIVE);
    PatternCreator pc = PatternCreator.INSTANCE;
    Patterns patterns = pc.getLibraryInstallPattern(instance, installConfig.dataverseName, installConfig.libraryName, installConfig.libraryPath);
    AsterixEventService.getAsterixEventServiceClient(instance.getCluster()).submit(patterns);
    LOGGER.info("Installed library " + installConfig.libraryName);
}
Also used : PatternCreator(org.apache.asterix.event.util.PatternCreator) AsterixInstance(org.apache.asterix.event.model.AsterixInstance) Patterns(org.apache.asterix.event.schema.pattern.Patterns)

Example 2 with PatternCreator

use of org.apache.asterix.event.util.PatternCreator in project asterixdb by apache.

the class UninstallConfig method execCommand.

@Override
protected void execCommand() throws Exception {
    InstallerDriver.initConfig(true);
    UninstallConfig uninstallConfig = ((UninstallConfig) config);
    String instanceName = uninstallConfig.name;
    AsterixEventServiceUtil.validateAsterixInstanceExists(instanceName, State.INACTIVE);
    ILookupService lookupService = ServiceProvider.INSTANCE.getLookupService();
    AsterixInstance instance = lookupService.getAsterixInstance(instanceName);
    PatternCreator pc = PatternCreator.INSTANCE;
    Patterns patterns = pc.getLibraryUninstallPattern(instance, uninstallConfig.dataverseName, uninstallConfig.libraryName);
    AsterixEventServiceClient client = AsterixEventService.getAsterixEventServiceClient(instance.getCluster());
    client.submit(patterns);
    LOGGER.info("Uninstalled library " + uninstallConfig.libraryName);
}
Also used : AsterixEventServiceClient(org.apache.asterix.event.management.AsterixEventServiceClient) PatternCreator(org.apache.asterix.event.util.PatternCreator) AsterixInstance(org.apache.asterix.event.model.AsterixInstance) Patterns(org.apache.asterix.event.schema.pattern.Patterns) ILookupService(org.apache.asterix.event.service.ILookupService)

Example 3 with PatternCreator

use of org.apache.asterix.event.util.PatternCreator in project asterixdb by apache.

the class LogConfig method execCommand.

@Override
protected void execCommand() throws Exception {
    InstallerDriver.initConfig(true);
    String asterixInstanceName = ((LogConfig) config).name;
    AsterixInstance instance = AsterixEventServiceUtil.validateAsterixInstanceExists(asterixInstanceName, State.INACTIVE, State.UNUSABLE, State.ACTIVE);
    PatternCreator pc = PatternCreator.INSTANCE;
    AsterixEventServiceClient eventrixClient = AsterixEventService.getAsterixEventServiceClient(instance.getCluster(), true, false);
    String outputDir = ((LogConfig) config).outputDir == null ? InstallerDriver.getManagixHome() + File.separator + "logdump" : ((LogConfig) config).outputDir;
    File f = new File(outputDir);
    String outputDirPath = f.getAbsolutePath();
    if (!f.exists()) {
        boolean success = f.mkdirs();
        if (!success) {
            throw new InstallerException("Unable to create output directory:" + outputDirPath);
        }
    }
    Patterns transferLogPattern = pc.getGenerateLogPattern(instance.getCluster(), outputDirPath);
    eventrixClient.submit(transferLogPattern);
    File outputDirFile = new File(outputDirPath);
    final String destFileName = "log_" + new Date().toString().replace(' ', '_') + ".zip";
    File destFile = new File(outputDirFile, destFileName);
    AsterixEventServiceUtil.zipDir(outputDirFile, destFile);
    String[] filesToDelete = outputDirFile.list(new FilenameFilter() {

        @Override
        public boolean accept(File dir, String name) {
            return !name.equals(destFileName);
        }
    });
    for (String fileS : filesToDelete) {
        f = new File(outputDirFile, fileS);
        if (f.isDirectory()) {
            FileUtils.deleteDirectory(f);
        } else {
            f.delete();
        }
    }
    LOGGER.info("Log zip archive created at " + destFile.getAbsolutePath());
}
Also used : Date(java.util.Date) FilenameFilter(java.io.FilenameFilter) AsterixEventServiceClient(org.apache.asterix.event.management.AsterixEventServiceClient) PatternCreator(org.apache.asterix.event.util.PatternCreator) AsterixInstance(org.apache.asterix.event.model.AsterixInstance) InstallerException(org.apache.asterix.installer.error.InstallerException) File(java.io.File) Patterns(org.apache.asterix.event.schema.pattern.Patterns)

Aggregations

AsterixInstance (org.apache.asterix.event.model.AsterixInstance)3 Patterns (org.apache.asterix.event.schema.pattern.Patterns)3 PatternCreator (org.apache.asterix.event.util.PatternCreator)3 AsterixEventServiceClient (org.apache.asterix.event.management.AsterixEventServiceClient)2 File (java.io.File)1 FilenameFilter (java.io.FilenameFilter)1 Date (java.util.Date)1 ILookupService (org.apache.asterix.event.service.ILookupService)1 InstallerException (org.apache.asterix.installer.error.InstallerException)1