Search in sources :

Example 6 with AsterixConfiguration

use of org.apache.asterix.common.configuration.AsterixConfiguration in project asterixdb by apache.

the class AlterConfig method execCommand.

@Override
protected void execCommand() throws Exception {
    InstallerDriver.initConfig(true);
    String instanceName = ((AlterConfig) config).name;
    AsterixEventServiceUtil.validateAsterixInstanceExists(instanceName, State.INACTIVE);
    ILookupService lookupService = ServiceProvider.INSTANCE.getLookupService();
    AsterixInstance instance = ServiceProvider.INSTANCE.getLookupService().getAsterixInstance(instanceName);
    AsterixEventServiceUtil.createClusterProperties(instance.getCluster(), instance.getAsterixConfiguration());
    AsterixConfiguration asterixConfiguration = InstallerUtil.getAsterixConfiguration(((AlterConfig) config).confPath);
    instance.setAsterixConfiguration(asterixConfiguration);
    instance.setModifiedTimestamp(new Date());
    lookupService.updateAsterixInstance(instance);
    LOGGER.info("Altered configuration settings for Asterix instance: " + instanceName);
}
Also used : AsterixConfiguration(org.apache.asterix.common.configuration.AsterixConfiguration) AsterixInstance(org.apache.asterix.event.model.AsterixInstance) Date(java.util.Date) ILookupService(org.apache.asterix.event.service.ILookupService)

Example 7 with AsterixConfiguration

use of org.apache.asterix.common.configuration.AsterixConfiguration in project asterixdb by apache.

the class CheckpointingTest method setUp.

@Before
public void setUp() throws Exception {
    System.out.println("SetUp: ");
    TestHelper.deleteExistingInstanceFiles();
    // Read default test configurations
    AsterixConfiguration ac = TestHelper.getConfigurations(DEFAULT_TEST_CONFIG_FILE_NAME);
    // Set log file size to 2MB
    ac.getProperty().add(new Property(TransactionProperties.TXN_LOG_PARTITIONSIZE_KEY, String.valueOf(TXN_LOG_PARTITION_SIZE), ""));
    // Disable checkpointing by making checkpoint thread wait max wait time
    ac.getProperty().add(new Property(TransactionProperties.TXN_LOG_CHECKPOINT_POLLFREQUENCY_KEY, String.valueOf(Integer.MAX_VALUE), ""));
    // Write test config file
    TestHelper.writeConfigurations(ac, TEST_CONFIG_FILE_PATH);
}
Also used : AsterixConfiguration(org.apache.asterix.common.configuration.AsterixConfiguration) Property(org.apache.asterix.common.configuration.Property) Before(org.junit.Before)

Example 8 with AsterixConfiguration

use of org.apache.asterix.common.configuration.AsterixConfiguration in project asterixdb by apache.

the class AsterixYARNClient method writeAsterixConfig.

/**
     * Retrieves necessary information from the cluster configuration and splices it into the Asterix configuration parameters
     *
     * @param cluster
     * @throws FileNotFoundException
     * @throws IOException
     */
private void writeAsterixConfig(Cluster cluster) throws FileNotFoundException, IOException {
    String metadataNodeId = Utils.getMetadataNode(cluster).getId();
    String asterixInstanceName = instanceName;
    AsterixConfiguration configuration = locateConfig();
    readConfigParams(configuration);
    String version = Utils.getAsterixVersionFromClasspath();
    configuration.setVersion(version);
    configuration.setInstanceName(asterixInstanceName);
    List<Store> stores = new ArrayList<Store>();
    String storeDir = cluster.getStore().trim();
    for (Node node : cluster.getNode()) {
        String iodevices = node.getIodevices() == null ? cluster.getIodevices() : node.getIodevices();
        String[] nodeIdDevice = iodevices.split(",");
        StringBuilder nodeStores = new StringBuilder();
        for (int i = 0; i < nodeIdDevice.length; i++) {
            nodeStores.append(nodeIdDevice[i] + File.separator + storeDir + ",");
        }
        //remove last comma
        nodeStores.deleteCharAt(nodeStores.length() - 1);
        stores.add(new Store(node.getId(), nodeStores.toString()));
    }
    configuration.setStore(stores);
    List<Coredump> coredump = new ArrayList<Coredump>();
    String coredumpdir = null;
    List<TransactionLogDir> txnLogDirs = new ArrayList<TransactionLogDir>();
    String txnLogDir = null;
    for (Node node : cluster.getNode()) {
        coredumpdir = node.getLogDir() == null ? cluster.getLogDir() : node.getLogDir();
        coredump.add(new Coredump(node.getId(), coredumpdir + "coredump" + File.separator));
        //node or cluster-wide
        txnLogDir = node.getTxnLogDir() == null ? cluster.getTxnLogDir() : node.getTxnLogDir();
        txnLogDirs.add(new TransactionLogDir(node.getId(), txnLogDir + (txnLogDir.charAt(txnLogDir.length() - 1) == File.separatorChar ? File.separator : "") + //if the string doesn't have a trailing / add one
        "txnLogs" + File.separator));
    }
    configuration.setMetadataNode(metadataNodeId);
    configuration.setCoredump(coredump);
    configuration.setTransactionLogDir(txnLogDirs);
    FileOutputStream os = new FileOutputStream(MERGED_PARAMETERS_PATH);
    try {
        JAXBContext ctx = JAXBContext.newInstance(AsterixConfiguration.class);
        Marshaller marshaller = ctx.createMarshaller();
        marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
        marshaller.marshal(configuration, os);
    } catch (JAXBException e) {
        throw new IOException(e);
    } finally {
        os.close();
    }
}
Also used : Marshaller(javax.xml.bind.Marshaller) AsterixConfiguration(org.apache.asterix.common.configuration.AsterixConfiguration) TransactionLogDir(org.apache.asterix.common.configuration.TransactionLogDir) Node(org.apache.asterix.event.schema.yarnCluster.Node) JAXBException(javax.xml.bind.JAXBException) ArrayList(java.util.ArrayList) Store(org.apache.asterix.common.configuration.Store) JAXBContext(javax.xml.bind.JAXBContext) IOException(java.io.IOException) FileOutputStream(java.io.FileOutputStream) Coredump(org.apache.asterix.common.configuration.Coredump)

Example 9 with AsterixConfiguration

use of org.apache.asterix.common.configuration.AsterixConfiguration in project asterixdb by apache.

the class AsterixEventServiceUtil method writeAsterixConfigurationFile.

private static void writeAsterixConfigurationFile(AsterixInstance asterixInstance) throws IOException, JAXBException {
    String asterixInstanceName = asterixInstance.getName();
    Cluster cluster = asterixInstance.getCluster();
    String metadataNodeId = asterixInstance.getMetadataNodeId();
    AsterixConfiguration configuration = asterixInstance.getAsterixConfiguration();
    configuration.setInstanceName(asterixInstanceName);
    configuration.setMetadataNode(asterixInstanceName + "_" + metadataNodeId);
    List<Store> stores = new ArrayList<Store>();
    String storeDir = cluster.getStore().trim();
    for (Node node : cluster.getNode()) {
        String iodevices = node.getIodevices() == null ? cluster.getIodevices() : node.getIodevices();
        String[] nodeIdDevice = iodevices.split(",");
        StringBuilder nodeStores = new StringBuilder();
        for (int i = 0; i < nodeIdDevice.length; i++) {
            nodeStores.append(nodeIdDevice[i] + File.separator + storeDir + ",");
        }
        //remove last comma
        nodeStores.deleteCharAt(nodeStores.length() - 1);
        stores.add(new Store(asterixInstanceName + "_" + node.getId(), nodeStores.toString()));
    }
    configuration.setStore(stores);
    List<Coredump> coredump = new ArrayList<Coredump>();
    List<TransactionLogDir> txnLogDirs = new ArrayList<TransactionLogDir>();
    for (Node node : cluster.getNode()) {
        String coredumpdir = node.getLogDir() == null ? cluster.getLogDir() : node.getLogDir();
        coredump.add(new Coredump(asterixInstanceName + "_" + node.getId(), coredumpdir + File.separator + asterixInstanceName + "_" + node.getId()));
        String txnLogDir = node.getTxnLogDir() == null ? cluster.getTxnLogDir() : node.getTxnLogDir();
        txnLogDirs.add(new TransactionLogDir(asterixInstanceName + "_" + node.getId(), txnLogDir));
    }
    configuration.setCoredump(coredump);
    configuration.setTransactionLogDir(txnLogDirs);
    File asterixConfDir = new File(AsterixEventService.getAsterixDir() + File.separator + asterixInstanceName);
    asterixConfDir.mkdirs();
    JAXBContext ctx = JAXBContext.newInstance(AsterixConfiguration.class);
    Marshaller marshaller = ctx.createMarshaller();
    marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
    FileOutputStream os = new FileOutputStream(asterixConfDir + File.separator + ASTERIX_CONFIGURATION_FILE);
    marshaller.marshal(configuration, os);
    os.close();
}
Also used : Marshaller(javax.xml.bind.Marshaller) AsterixConfiguration(org.apache.asterix.common.configuration.AsterixConfiguration) TransactionLogDir(org.apache.asterix.common.configuration.TransactionLogDir) Node(org.apache.asterix.event.schema.cluster.Node) ArrayList(java.util.ArrayList) Cluster(org.apache.asterix.event.schema.cluster.Cluster) Store(org.apache.asterix.common.configuration.Store) JAXBContext(javax.xml.bind.JAXBContext) FileOutputStream(java.io.FileOutputStream) Coredump(org.apache.asterix.common.configuration.Coredump) JarFile(java.util.jar.JarFile) File(java.io.File)

Aggregations

AsterixConfiguration (org.apache.asterix.common.configuration.AsterixConfiguration)9 JAXBContext (javax.xml.bind.JAXBContext)6 File (java.io.File)4 Unmarshaller (javax.xml.bind.Unmarshaller)4 JAXBException (javax.xml.bind.JAXBException)3 FileOutputStream (java.io.FileOutputStream)2 IOException (java.io.IOException)2 ArrayList (java.util.ArrayList)2 Marshaller (javax.xml.bind.Marshaller)2 Coredump (org.apache.asterix.common.configuration.Coredump)2 Store (org.apache.asterix.common.configuration.Store)2 TransactionLogDir (org.apache.asterix.common.configuration.TransactionLogDir)2 AsterixException (org.apache.asterix.common.exceptions.AsterixException)2 InputStream (java.io.InputStream)1 Date (java.util.Date)1 JarFile (java.util.jar.JarFile)1 Property (org.apache.asterix.common.configuration.Property)1 AsterixInstance (org.apache.asterix.event.model.AsterixInstance)1 Cluster (org.apache.asterix.event.schema.cluster.Cluster)1 Node (org.apache.asterix.event.schema.cluster.Node)1