Search in sources :

Example 1 with SyncCallback

use of org.voltdb.client.SyncCallback in project voltdb by VoltDB.

the class HealthMonitor method checkDRRole.

private void checkDRRole() {
    SyncCallback cb = new SyncCallback();
    if (getConnectionHadler().callProcedure(getInternalUser(), false, BatchTimeoutOverrideType.NO_TIMEOUT, cb, "@Statistics", "DRROLE", 0)) {
        try {
            cb.waitForResponse();
        } catch (InterruptedException e) {
            m_logger.error("Interrupted while retrieving cluster for DRROLE STATS", e);
            return;
        }
        ClientResponse r = cb.getResponse();
        if (r.getStatus() != ClientResponse.SUCCESS) {
            // timeout could happen if hostdown
            if (m_logger.isDebugEnabled()) {
                m_logger.debug("Unable to retrieve DRROLE STATS: " + r.getStatusString());
            }
            return;
        }
        VoltTable result = r.getResults()[0];
        while (result.advanceRow()) {
            DrRoleType drRole = DrRoleType.fromValue(result.getString(DRRoleStats.CN_ROLE).toLowerCase());
            DRRoleStats.State state = DRRoleStats.State.valueOf(result.getString(DRRoleStats.CN_STATE));
            byte remoteCluster = (byte) result.getLong(DRRoleStats.CN_REMOTE_CLUSTER_ID);
            if (m_logger.isDebugEnabled()) {
                m_logger.debug("DRROLE stats: Role:" + drRole + " State:" + state + " Remote Cluster ID:" + remoteCluster);
            }
            if (drRole == DrRoleType.NONE) {
                continue;
            }
            if (DRRoleStats.State.STOPPED == state) {
                if (!m_snmpDRTrapSent.getOrDefault(remoteCluster, false)) {
                    m_snmpTrapSender.statistics(FaultFacility.DR, String.format("Database Replication ROLE: %s break with Remote Cluster %d.", drRole, remoteCluster));
                    m_snmpDRTrapSent.put(remoteCluster, true);
                }
            } else {
                // reset
                if (m_snmpDRTrapSent.getOrDefault(remoteCluster, false)) {
                    m_snmpDRTrapSent.put(remoteCluster, false);
                }
            }
        }
    } else {
        m_logger.error("Unable to retrieve DRROLE STATS:: failed to invoke @Statistics DRROLE, 0.");
    }
}
Also used : ClientResponse(org.voltdb.client.ClientResponse) DrRoleType(org.voltdb.compiler.deploymentfile.DrRoleType) SyncCallback(org.voltdb.client.SyncCallback)

Example 2 with SyncCallback

use of org.voltdb.client.SyncCallback in project voltdb by VoltDB.

the class TestUpdateDeployment method testUpdateBadExport.

public void testUpdateBadExport() throws Exception {
    System.out.println("\n\n-----\n testUpdateBadExport \n-----\n\n");
    System.setProperty(ExportDataProcessor.EXPORT_TO_TYPE, "org.voltdb.export.ExportTestClient");
    Map<String, String> additionalEnv = new HashMap<>();
    additionalEnv.put(ExportDataProcessor.EXPORT_TO_TYPE, "org.voltdb.export.ExportTestClient");
    LocalCluster config = new LocalCluster("catalogupdate-bad-export.jar", SITES_PER_HOST, HOSTS, K, BackendTarget.NATIVE_EE_JNI, LocalCluster.FailureState.ALL_RUNNING, true, false, additionalEnv);
    TPCCProjectBuilder project = new TPCCProjectBuilder();
    project.addDefaultSchema();
    project.addDefaultPartitioning();
    project.addProcedures(BASEPROCS);
    Properties props = buildProperties("type", "csv", "batched", "false", "with-schema", "true", "complain", "true", "outdir", "/tmp/" + System.getProperty("user.name"));
    project.addExport(true, /* enabled */
    "custom", props);
    // build the jarfile
    boolean compile = config.compile(project);
    assertTrue(compile);
    Client client = getClient();
    loadSomeData(client, 0, 10);
    client.drain();
    assertTrue(callbackSuccess);
    // Try to change the schem setting
    SyncCallback cb = new SyncCallback();
    client.updateApplicationCatalog(cb, null, new File(project.getPathToDeployment()));
    cb.waitForResponse();
    assertEquals(ClientResponse.GRACEFUL_FAILURE, cb.getResponse().getStatus());
    System.out.println(cb.getResponse().getStatusString());
    assertTrue(cb.getResponse().getStatusString().contains("Unable to update"));
}
Also used : HashMap(java.util.HashMap) Properties(java.util.Properties) Client(org.voltdb.client.Client) TPCCProjectBuilder(org.voltdb.benchmark.tpcc.TPCCProjectBuilder) SyncCallback(org.voltdb.client.SyncCallback) File(java.io.File)

Example 3 with SyncCallback

use of org.voltdb.client.SyncCallback in project voltdb by VoltDB.

the class TestCatalogUpdateSuite method testUpdate.

public void testUpdate() throws Exception {
    Client client = getClient();
    String newCatalogURL;
    String deploymentURL;
    VoltTable[] results;
    CatTestCallback callback;
    loadSomeData(client, 0, 25);
    assertCallbackSuccess(client);
    negativeTests(client);
    assertCallbackSuccess(client);
    // asynchronously call some random inserts
    loadSomeData(client, 25, 25);
    assertCallbackSuccess(client);
    // add a procedure "InsertOrderLineBatched"
    newCatalogURL = Configuration.getPathToCatalogForTest("catalogupdate-cluster-expanded.jar");
    deploymentURL = Configuration.getPathToCatalogForTest("catalogupdate-cluster-expanded.xml");
    callback = new CatTestCallback(ClientResponse.SUCCESS);
    client.updateApplicationCatalog(callback, new File(newCatalogURL), new File(deploymentURL));
    // don't care if this succeeds or fails.
    // calling the new proc before the cat change returns is not guaranteed to work
    // we just hope it doesn't crash anything
    int x = 3;
    SyncCallback cb = new SyncCallback();
    client.callProcedure(cb, org.voltdb.benchmark.tpcc.procedures.InsertOrderLineBatched.class.getSimpleName(), new long[] { x }, new long[] { x }, x, new long[] { x }, new long[] { x }, new long[] { x }, new TimestampType[] { new TimestampType() }, new long[] { x }, new double[] { x }, new String[] { "a" });
    cb.waitForResponse();
    // make sure the previous catalog change has completed
    assertCallbackSuccess(client);
    // now calling the new proc better work
    x = 2;
    client.callProcedure(org.voltdb.benchmark.tpcc.procedures.InsertOrderLineBatched.class.getSimpleName(), new long[] { x }, new long[] { x }, (short) x, new long[] { x }, new long[] { x }, new long[] { x }, new TimestampType[] { new TimestampType() }, new long[] { x }, new double[] { x }, new String[] { "a" });
    loadSomeData(client, 50, 5);
    assertCallbackSuccess(client);
    // this is a do nothing change... shouldn't affect anything
    newCatalogURL = Configuration.getPathToCatalogForTest("catalogupdate-cluster-expanded.jar");
    deploymentURL = Configuration.getPathToCatalogForTest("catalogupdate-cluster-expanded.xml");
    results = client.updateApplicationCatalog(new File(newCatalogURL), new File(deploymentURL)).getResults();
    assertTrue(results.length == 1);
    assertCallbackSuccess(client);
    // now calling the new proc better work
    x = 4;
    client.callProcedure(org.voltdb.benchmark.tpcc.procedures.InsertOrderLineBatched.class.getSimpleName(), new long[] { x }, new long[] { x }, (short) x, new long[] { x }, new long[] { x }, new long[] { x }, new TimestampType[] { new TimestampType() }, new long[] { x }, new double[] { x }, new String[] { "a" });
    loadSomeData(client, 55, 5);
    // remove the procedure we just added async
    newCatalogURL = Configuration.getPathToCatalogForTest("catalogupdate-cluster-base.jar");
    deploymentURL = Configuration.getPathToCatalogForTest("catalogupdate-cluster-base.xml");
    callback = new CatTestCallback(ClientResponse.SUCCESS);
    client.updateApplicationCatalog(new File(newCatalogURL), new File(deploymentURL));
    // don't care if this works now
    x = 4;
    cb = new SyncCallback();
    client.callProcedure(cb, org.voltdb.benchmark.tpcc.procedures.InsertOrderLineBatched.class.getSimpleName(), new long[] { x }, new long[] { x }, (short) x, new long[] { x }, new long[] { x }, new long[] { x }, new TimestampType[] { new TimestampType() }, new long[] { x }, new double[] { x }, new String[] { "a" });
    cb.waitForResponse();
    // make sure the previous catalog change has completed
    assertCallbackSuccess(client);
    // now calling the new proc better fail
    x = 5;
    cb = new SyncCallback();
    client.callProcedure(cb, org.voltdb.benchmark.tpcc.procedures.InsertOrderLineBatched.class.getSimpleName(), new long[] { x }, new long[] { x }, (short) x, new long[] { x }, new long[] { x }, new long[] { x }, new TimestampType[] { new TimestampType() }, new long[] { x }, new double[] { x }, new String[] { "a" });
    cb.waitForResponse();
    assertNotSame(cb.getResponse().getStatus(), ClientResponse.SUCCESS);
    loadSomeData(client, 60, 5);
    // change the insert new order procedure
    newCatalogURL = Configuration.getPathToCatalogForTest("catalogupdate-cluster-conflict.jar");
    deploymentURL = Configuration.getPathToCatalogForTest("catalogupdate-cluster-conflict.xml");
    results = client.updateApplicationCatalog(new File(newCatalogURL), new File(deploymentURL)).getResults();
    assertTrue(results.length == 1);
    // call the new proc and make sure the one we want gets run
    results = client.callProcedure(InsertNewOrder.class.getSimpleName(), 100, 100, 100, 100, (short) 100, 100, 1.0, "a").getResults();
    assertEquals(1, results.length);
    assertEquals(1776, results[0].asScalarLong());
    // load a big catalog change just to make sure nothing fails horribly
    newCatalogURL = Configuration.getPathToCatalogForTest("catalogupdate-cluster-many.jar");
    deploymentURL = Configuration.getPathToCatalogForTest("catalogupdate-cluster-many.xml");
    results = client.updateApplicationCatalog(new File(newCatalogURL), new File(deploymentURL)).getResults();
    assertTrue(results.length == 1);
    loadSomeData(client, 65, 5);
    //Check that if a catalog update blocker exists the catalog update fails
    ZooKeeper zk = ZKUtil.getClient(((LocalCluster) m_config).zkinterface(0), 10000, new HashSet<Long>());
    final String catalogUpdateBlockerPath = zk.create(VoltZK.elasticJoinActiveBlocker, null, ZooDefs.Ids.OPEN_ACL_UNSAFE, CreateMode.EPHEMERAL_SEQUENTIAL);
    try {
        /*
             * Update the catalog and expect failure
             */
        newCatalogURL = Configuration.getPathToCatalogForTest("catalogupdate-cluster-base.jar");
        deploymentURL = Configuration.getPathToCatalogForTest("catalogupdate-cluster-base.xml");
        boolean threw = false;
        try {
            client.updateApplicationCatalog(new File(newCatalogURL), new File(deploymentURL));
        } catch (ProcCallException e) {
            e.printStackTrace();
            threw = true;
        }
        assertTrue(threw);
    } finally {
        zk.delete(catalogUpdateBlockerPath, -1);
    }
    //Expect success
    client.updateApplicationCatalog(new File(newCatalogURL), new File(deploymentURL));
    assertCallbackSuccess(client);
    assertTrue(true);
}
Also used : VoltTable(org.voltdb.VoltTable) SyncCallback(org.voltdb.client.SyncCallback) ZooKeeper(org.apache.zookeeper_voltpatches.ZooKeeper) TimestampType(org.voltdb.types.TimestampType) Client(org.voltdb.client.Client) File(java.io.File) InsertNewOrder(org.voltdb.benchmark.tpcc.procedures.InsertNewOrder) ProcCallException(org.voltdb.client.ProcCallException)

Example 4 with SyncCallback

use of org.voltdb.client.SyncCallback in project voltdb by VoltDB.

the class TestUpdateDeployment method testBadMaskPassword.

public void testBadMaskPassword() throws Exception {
    System.out.println("\n\n-----\n testBadMaskPassword \n-----\n\n");
    Client client = getClient();
    loadSomeData(client, 0, 10);
    client.drain();
    assertTrue(callbackSuccess);
    String deploymentURL = Configuration.getPathToCatalogForTest("catalogupdate-bad-masked-password.xml");
    // Try to change schema setting
    SyncCallback cb = new SyncCallback();
    client.updateApplicationCatalog(cb, null, new File(deploymentURL));
    cb.waitForResponse();
    assertEquals(ClientResponse.GRACEFUL_FAILURE, cb.getResponse().getStatus());
    assertTrue(cb.getResponse().getStatusString().contains("Unable to update deployment configuration"));
}
Also used : Client(org.voltdb.client.Client) SyncCallback(org.voltdb.client.SyncCallback) File(java.io.File)

Example 5 with SyncCallback

use of org.voltdb.client.SyncCallback in project voltdb by VoltDB.

the class TestGroupBySuite method loadF.

/** load known data to F without loading the Dimension tables
     * @throws InterruptedException */
private int loadF(Client client, int pkey) throws NoConnectionsException, ProcCallException, IOException, InterruptedException {
    VoltTable vt;
    // if you want to test synchronous latency, this
    //  is a good variable to change
    boolean async = true;
    for (int i = 0; i < 1000; i++) {
        // 10 unique dim1s
        int f_d1 = i % 10;
        // 50 unique dim2s
        int f_d2 = i % 50;
        // 100 unique dim3s
        int f_d3 = i % 100;
        boolean done;
        SyncCallback cb = new SyncCallback();
        do {
            done = client.callProcedure(cb, "InsertF", pkey++, f_d1, f_d2, f_d3, 2, (i * 10), (i % 2));
            if (!done) {
                client.backpressureBarrier();
            }
        } while (!done);
        if (!async) {
            cb.waitForResponse();
            vt = cb.getResponse().getResults()[0];
            assertTrue(vt.getRowCount() == 1);
        // assertTrue(vt.asScalarLong() == 1);
        }
    }
    client.drain();
    return pkey;
}
Also used : VoltTable(org.voltdb.VoltTable) SyncCallback(org.voltdb.client.SyncCallback)

Aggregations

SyncCallback (org.voltdb.client.SyncCallback)15 Client (org.voltdb.client.Client)9 File (java.io.File)8 VoltTable (org.voltdb.VoltTable)6 ClientResponse (org.voltdb.client.ClientResponse)2 TimestampType (org.voltdb.types.TimestampType)2 HashMap (java.util.HashMap)1 Properties (java.util.Properties)1 AtomicLong (java.util.concurrent.atomic.AtomicLong)1 ZooKeeper (org.apache.zookeeper_voltpatches.ZooKeeper)1 TPCCProjectBuilder (org.voltdb.benchmark.tpcc.TPCCProjectBuilder)1 InsertNewOrder (org.voltdb.benchmark.tpcc.procedures.InsertNewOrder)1 ProcCallException (org.voltdb.client.ProcCallException)1 DrRoleType (org.voltdb.compiler.deploymentfile.DrRoleType)1