Search in sources :

Example 6 with DeploymentType

use of org.voltdb.compiler.deploymentfile.DeploymentType in project voltdb by VoltDB.

the class TestJSONInterface method testUpdateDeployment.

public void testUpdateDeployment() throws Exception {
    try {
        String simpleSchema = "CREATE TABLE foo (\n" + "    bar BIGINT NOT NULL,\n" + "    PRIMARY KEY (bar)\n" + ");";
        File schemaFile = VoltProjectBuilder.writeStringToTempFile(simpleSchema);
        String schemaPath = schemaFile.getPath();
        schemaPath = URLEncoder.encode(schemaPath, "UTF-8");
        VoltProjectBuilder builder = new VoltProjectBuilder();
        builder.addSchema(schemaPath);
        builder.addPartitionInfo("foo", "bar");
        builder.addProcedures(DelayProc.class);
        builder.setHTTPDPort(8095);
        boolean success = builder.compile(Configuration.getPathToCatalogForTest("json.jar"));
        assertTrue(success);
        VoltDB.Configuration config = new VoltDB.Configuration();
        config.m_pathToCatalog = config.setPathToCatalogForTest("json.jar");
        config.m_pathToDeployment = builder.getPathToDeployment();
        server = new ServerThread(config);
        server.start();
        server.waitForInitialization();
        //Get deployment
        String jdep = getUrlOverJSON(protocolPrefix + "localhost:8095/deployment", null, null, null, 200, "application/json");
        assertTrue(jdep.contains("cluster"));
        //POST deployment with no content
        String pdep = postUrlOverJSON(protocolPrefix + "localhost:8095/deployment/", null, null, null, 400, "application/json", null);
        assertTrue(pdep.contains("Failed"));
        Map<String, String> params = new HashMap<>();
        params.put("deployment", jdep);
        pdep = postUrlOverJSON(protocolPrefix + "localhost:8095/deployment/", null, null, null, 200, "application/json", params);
        assertTrue(pdep.contains("Deployment Updated"));
        //POST deployment in admin mode
        params.put("admin", "true");
        pdep = postUrlOverJSON(protocolPrefix + "localhost:8095/deployment/", null, null, null, 200, "application/json", params);
        assertTrue(pdep.contains("Deployment Updated"));
        ObjectMapper mapper = new ObjectMapper();
        DeploymentType deptype = mapper.readValue(jdep, DeploymentType.class);
        //Test change heartbeat.
        if (deptype.getHeartbeat() == null) {
            HeartbeatType hb = new HeartbeatType();
            hb.setTimeout(99);
            deptype.setHeartbeat(hb);
        } else {
            deptype.getHeartbeat().setTimeout(99);
        }
        String ndeptype = mapper.writeValueAsString(deptype);
        params.put("deployment", ndeptype);
        pdep = postUrlOverJSON(protocolPrefix + "localhost:8095/deployment/", null, null, null, 200, "application/json", params);
        System.out.println("POST result is: " + pdep);
        assertTrue(pdep.contains("Deployment Updated"));
        jdep = getUrlOverJSON(protocolPrefix + "localhost:8095/deployment", null, null, null, 200, "application/json");
        assertTrue(jdep.contains("cluster"));
        deptype = mapper.readValue(jdep, DeploymentType.class);
        int nto = deptype.getHeartbeat().getTimeout();
        assertEquals(99, nto);
        //Test change Query timeout
        SystemSettingsType ss = deptype.getSystemsettings();
        if (ss == null) {
            ss = new SystemSettingsType();
            deptype.setSystemsettings(ss);
        }
        Query qv = ss.getQuery();
        if (qv == null) {
            qv = new Query();
            qv.setTimeout(99);
        } else {
            qv.setTimeout(99);
        }
        ss.setQuery(qv);
        deptype.setSystemsettings(ss);
        ndeptype = mapper.writeValueAsString(deptype);
        params.put("deployment", ndeptype);
        pdep = postUrlOverJSON(protocolPrefix + "localhost:8095/deployment/", null, null, null, 200, "application/json", params);
        System.out.println("POST result is: " + pdep);
        assertTrue(pdep.contains("Deployment Updated"));
        jdep = getUrlOverJSON(protocolPrefix + "localhost:8095/deployment", null, null, null, 200, "application/json");
        assertTrue(jdep.contains("cluster"));
        deptype = mapper.readValue(jdep, DeploymentType.class);
        nto = deptype.getSystemsettings().getQuery().getTimeout();
        assertEquals(99, nto);
        qv.setTimeout(88);
        ss.setQuery(qv);
        deptype.setSystemsettings(ss);
        ndeptype = mapper.writeValueAsString(deptype);
        params.put("deployment", ndeptype);
        pdep = postUrlOverJSON(protocolPrefix + "localhost:8095/deployment/", null, null, null, 200, "application/json", params);
        System.out.println("POST result is: " + pdep);
        assertTrue(pdep.contains("Deployment Updated"));
        jdep = getUrlOverJSON(protocolPrefix + "localhost:8095/deployment", null, null, null, 200, "application/json");
        assertTrue(jdep.contains("cluster"));
        deptype = mapper.readValue(jdep, DeploymentType.class);
        nto = deptype.getSystemsettings().getQuery().getTimeout();
        assertEquals(88, nto);
    } finally {
        if (server != null) {
            server.shutdown();
            server.join();
        }
        server = null;
    }
}
Also used : Configuration(org.voltdb.VoltDB.Configuration) Query(org.voltdb.compiler.deploymentfile.SystemSettingsType.Query) HashMap(java.util.HashMap) DeploymentType(org.voltdb.compiler.deploymentfile.DeploymentType) HeartbeatType(org.voltdb.compiler.deploymentfile.HeartbeatType) SystemSettingsType(org.voltdb.compiler.deploymentfile.SystemSettingsType) VoltProjectBuilder(org.voltdb.compiler.VoltProjectBuilder) Configuration(org.voltdb.VoltDB.Configuration) File(java.io.File) ObjectMapper(org.codehaus.jackson.map.ObjectMapper)

Example 7 with DeploymentType

use of org.voltdb.compiler.deploymentfile.DeploymentType in project voltdb by VoltDB.

the class TestCatalogDiffs method testConnectorPropertiesChanges.

public void testConnectorPropertiesChanges() throws Exception {
    // not supported in community
    if (!MiscUtils.isPro()) {
        return;
    }
    String testDir = BuildDirectoryUtils.getBuildDirectoryPath();
    final String ddl = "CREATE STREAM export_data export to target default ( id BIGINT default 0 , value BIGINT DEFAULT 0 );";
    VoltProjectBuilder builder = new VoltProjectBuilder();
    builder.addLiteralSchema(ddl);
    final String origXml = "<?xml version='1.0' encoding='UTF-8' standalone='no'?>" + "<deployment>" + "<cluster hostcount='3' kfactor='1' sitesperhost='2'/>" + "    <export>" + "        <configuration target='default' enabled='true' type='file'>" + "            <property name=\"type\">CSV</property>" + "            <property name=\"with-schema\">false</property>" + "            <property name=\"nonce\">pre-fix</property>" + "            <property name=\"outdir\">" + m_dir + "</property>" + "        </configuration>" + "    </export>" + "</deployment>";
    builder.compile(testDir + File.separator + "propexport1.jar");
    Catalog origCat = catalogForJar(testDir + File.separator + "propexport1.jar");
    final File origFile = VoltProjectBuilder.writeStringToTempFile(origXml);
    DeploymentType origDepl = CatalogUtil.getDeployment(new FileInputStream(origFile));
    String msg = CatalogUtil.compileDeployment(origCat, origDepl, false);
    assertTrue("Deployment file failed to parse: " + msg, msg == null);
    final String newPropXml = "<?xml version='1.0' encoding='UTF-8' standalone='no'?>" + "<deployment>" + "<cluster hostcount='3' kfactor='1' sitesperhost='2'/>" + "    <export>" + "        <configuration target='default' enabled='true' type='file'>" + "            <property name=\"type\">CSV</property>" + "            <property name=\"with-schema\">false</property>" + "            <property name=\"nonce\">pre-fix</property>" + "            <property name=\"outdir\">" + m_dir + "</property>" + "            <property name=\"iamnew\">see_me_roar</property>" + "        </configuration>" + "    </export>" + "</deployment>";
    builder.compile(testDir + File.separator + "propexport2.jar");
    Catalog newPropCat = catalogForJar(testDir + File.separator + "propexport2.jar");
    final File newPropFile = VoltProjectBuilder.writeStringToTempFile(newPropXml);
    DeploymentType newPropDepl = CatalogUtil.getDeployment(new FileInputStream(newPropFile));
    msg = CatalogUtil.compileDeployment(newPropCat, newPropDepl, false);
    assertTrue("Deployment file failed to parse: " + msg, msg == null);
    final String modPropXml = "<?xml version='1.0' encoding='UTF-8' standalone='no'?>" + "<deployment>" + "<cluster hostcount='3' kfactor='1' sitesperhost='2'/>" + "    <export>" + "        <configuration target='default' enabled='true' type='file'>" + "            <property name=\"type\">TSV</property>" + "            <property name=\"with-schema\">true</property>" + "            <property name=\"nonce\">pre-fix-other</property>" + "            <property name=\"outdir\">" + m_dir + "</property>" + "        </configuration>" + "    </export>" + "</deployment>";
    builder.compile(testDir + File.separator + "propexport3.jar");
    Catalog modPropCat = catalogForJar(testDir + File.separator + "propexport3.jar");
    final File modPropFile = VoltProjectBuilder.writeStringToTempFile(modPropXml);
    DeploymentType modPropDepl = CatalogUtil.getDeployment(new FileInputStream(modPropFile));
    msg = CatalogUtil.compileDeployment(modPropCat, modPropDepl, false);
    assertTrue("Deployment file failed to parse: " + msg, msg == null);
    final String modTypeXml = "<?xml version='1.0' encoding='UTF-8' standalone='no'?>" + "<deployment>" + "<cluster hostcount='3' kfactor='1' sitesperhost='2'/>" + "    <export>" + "        <configuration target='default' enabled='false' type='custom' exportconnectorclass=\"org.voltdb.exportclient.NoOpTestExportClient\" >" + "            <property name=\"foo\">false</property>" + "            <property name=\"type\">CSV</property>" + "            <property name=\"with-schema\">false</property>" + "        </configuration>" + "    </export>" + "</deployment>";
    builder.compile(testDir + File.separator + "propexport4.jar");
    Catalog modTypeCat = catalogForJar(testDir + File.separator + "propexport4.jar");
    final File modTypeFile = VoltProjectBuilder.writeStringToTempFile(modTypeXml);
    DeploymentType modTypeDepl = CatalogUtil.getDeployment(new FileInputStream(modTypeFile));
    msg = CatalogUtil.compileDeployment(modTypeCat, modTypeDepl, false);
    assertTrue("Deployment file failed to parse: " + msg, msg == null);
    // test delete
    verifyDiff(newPropCat, origCat, null, null, true, true, false);
    // test add
    verifyDiff(origCat, newPropCat, null, null, true, true, false);
    // test modification
    verifyDiff(origCat, modPropCat, null, null, true, true, false);
    // test modification
    verifyDiff(modPropCat, modTypeCat, null, null, true, true, false);
}
Also used : VoltProjectBuilder(org.voltdb.compiler.VoltProjectBuilder) DeploymentType(org.voltdb.compiler.deploymentfile.DeploymentType) File(java.io.File) VoltFile(org.voltdb.utils.VoltFile) FileInputStream(java.io.FileInputStream)

Example 8 with DeploymentType

use of org.voltdb.compiler.deploymentfile.DeploymentType in project voltdb by VoltDB.

the class TestCatalogDiffs method generateCatalogWithDeployment.

private static Catalog generateCatalogWithDeployment(String ddl, String defaultDepXml) throws IOException {
    VoltProjectBuilder builder = new VoltProjectBuilder();
    builder.addLiteralSchema(ddl);
    final File jarPath = VoltFile.createTempFile("drrole", "jar");
    builder.compile(jarPath.getAbsolutePath());
    Catalog catalog = catalogForJar(jarPath.getAbsolutePath());
    File file = VoltProjectBuilder.writeStringToTempFile(defaultDepXml);
    DeploymentType deployment = CatalogUtil.getDeployment(new FileInputStream(file));
    CatalogUtil.compileDeployment(catalog, deployment, false);
    jarPath.delete();
    return catalog;
}
Also used : VoltProjectBuilder(org.voltdb.compiler.VoltProjectBuilder) DeploymentType(org.voltdb.compiler.deploymentfile.DeploymentType) File(java.io.File) VoltFile(org.voltdb.utils.VoltFile) FileInputStream(java.io.FileInputStream)

Example 9 with DeploymentType

use of org.voltdb.compiler.deploymentfile.DeploymentType in project voltdb by VoltDB.

the class TestInitStartLocalClusterAllOutOfProcess method testGetDeployment.

// Test get deployment
public void testGetDeployment() throws Exception {
    File deployment = File.createTempFile("get_deployment", ".xm");
    if (deployment.exists())
        deployment.delete();
    Configuration config = new VoltDB.Configuration(new String[] { "get", "deployment", "getvoltdbroot", voltDBRootParentPath, "file", deployment.getAbsolutePath() + "l", "forceget" });
    ServerThread server = new ServerThread(config);
    try {
        server.cli();
    } catch (Throwable ex) {
    //Good
    }
    DeploymentType dt = CatalogUtil.parseDeployment(deployment.getAbsolutePath() + "l");
    assertNotNull(dt);
    assertEquals(dt.getPaths().getVoltdbroot().getPath(), voltDbRootPath);
}
Also used : Configuration(org.voltdb.VoltDB.Configuration) ServerThread(org.voltdb.ServerThread) DeploymentType(org.voltdb.compiler.deploymentfile.DeploymentType) File(java.io.File)

Example 10 with DeploymentType

use of org.voltdb.compiler.deploymentfile.DeploymentType in project voltdb by VoltDB.

the class TestInitStartLocalClusterInProcess method testGetDeployment.

// Test get deployment
public void testGetDeployment() throws Exception {
    File deployment = File.createTempFile("get_deployment", ".xm");
    Configuration config = new VoltDB.Configuration(new String[] { "get", "deployment", "getvoltdbroot", voltDBRootParentPath, "file", deployment.getAbsolutePath() + "l", "forceget" });
    ServerThread server = new ServerThread(config);
    try {
        server.cli();
    } catch (Throwable ex) {
    //Good
    }
    DeploymentType dt = CatalogUtil.parseDeployment(deployment.getAbsolutePath() + "l");
    assertNotNull(dt);
    assertEquals(dt.getPaths().getVoltdbroot().getPath(), voltDbRootPath);
}
Also used : Configuration(org.voltdb.VoltDB.Configuration) ServerThread(org.voltdb.ServerThread) DeploymentType(org.voltdb.compiler.deploymentfile.DeploymentType) File(java.io.File)

Aggregations

DeploymentType (org.voltdb.compiler.deploymentfile.DeploymentType)27 File (java.io.File)20 FileInputStream (java.io.FileInputStream)9 VoltProjectBuilder (org.voltdb.compiler.VoltProjectBuilder)7 IOException (java.io.IOException)6 VoltFile (org.voltdb.utils.VoltFile)6 JAXBException (javax.xml.bind.JAXBException)5 Configuration (org.voltdb.VoltDB.Configuration)5 Catalog (org.voltdb.catalog.Catalog)5 JAXBContext (javax.xml.bind.JAXBContext)4 Marshaller (javax.xml.bind.Marshaller)4 UnsupportedEncodingException (java.io.UnsupportedEncodingException)3 SocketException (java.net.SocketException)3 HashMap (java.util.HashMap)3 ExecutionException (java.util.concurrent.ExecutionException)3 KeeperException (org.apache.zookeeper_voltpatches.KeeperException)3 ObjectMapper (org.codehaus.jackson.map.ObjectMapper)3 JSONException (org.json_voltpatches.JSONException)3 VoltCompiler (org.voltdb.compiler.VoltCompiler)3 ClusterType (org.voltdb.compiler.deploymentfile.ClusterType)3