Search in sources :

Example 76 with VoltTable

use of org.voltdb.VoltTable in project voltdb by VoltDB.

the class InsertT method run.

public VoltTable[] run(String T_PK1, String T_PK2, String V1, String V2, String S_PK, String V3, String V4, String V5, String V6, String V7, String V8, String V9, String V10, String V11, String V12, String V13, String V14, String V15, String TS1, String V16, String TS2, String V17, String V18, String V19, String V20, String V21, String V22, String V23, String V24, String BIGINT1, String T_PK3, String TS3, String V25, String TS4, String DECIMAL1, String V26, String bigint2, String bigint3, String bigint4, String bigint5, String bigint6, String bigint7, String V27, String BIGINT8, String TS5, String V28, String V29, String V30, String V31, String V32, String INT1) throws VoltAbortException {
    VoltTable[] retval = null;
    try {
        SimpleDateFormat sdf = new SimpleDateFormat("MMddyyyy");
        Long emptylong = new Long(0);
        Long s_pk = emptylong;
        if ((S_PK != null) && (!"".equals(S_PK))) {
            s_pk = Long.parseLong(S_PK);
        }
        Long bigint1 = emptylong;
        if ((BIGINT1 != null) && (!"".equals(BIGINT1.trim()))) {
            bigint1 = Long.parseLong(BIGINT1);
        }
        BigDecimal decimal1 = null;
        if ((DECIMAL1 != null) && (!"".equals(DECIMAL1))) {
            decimal1 = new BigDecimal(DECIMAL1);
        }
        TimestampType ts1 = null;
        TimestampType ts2 = null;
        if ((TS1 != null) && (!"".equals(TS1))) {
            Date tempdate = null;
            try {
                tempdate = sdf.parse(TS1);
                ts1 = new TimestampType(tempdate.getTime() * 1000);
            } catch (ParseException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        }
        if ((TS2 != null) && (!"".equals(TS2))) {
            Date tempdate = null;
            try {
                tempdate = sdf.parse(TS2);
                ts2 = new TimestampType(tempdate.getTime() * 1000);
            } catch (ParseException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        }
        TimestampType ts3 = null;
        if ((TS3 != null) && (!"".equals(TS3))) {
            Date tempdate = null;
            try {
                tempdate = sdf.parse(TS3);
                ts3 = new TimestampType(tempdate.getTime() * 1000);
            } catch (ParseException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        }
        TimestampType ts5 = null;
        if ((TS5 != null) && (!"".equals(TS5))) {
            Date tempdate = null;
            try {
                tempdate = sdf.parse(TS5);
                ts5 = new TimestampType(tempdate.getTime() * 1000);
            } catch (ParseException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        }
        TimestampType ts4 = null;
        if ((TS4 != null) && (!"".equals(TS4))) {
            Date tempdate = null;
            try {
                tempdate = sdf.parse(TS4);
                ts4 = new TimestampType(tempdate.getTime() * 1000);
            } catch (ParseException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        }
        Integer bigint8 = null;
        if ((BIGINT8 != null) && (!"".equals(BIGINT8))) {
            bigint8 = Integer.parseInt(BIGINT8);
        }
        Integer int1 = null;
        if ((INT1 != null) && (!"".equals(INT1))) {
            int1 = Integer.parseInt(INT1);
        }
        voltQueueSQL(sql, T_PK1, T_PK2, V1, V2, s_pk, V3, V4, V5, V6, V7, V8, V9, V10, V11, V12, V13, V14, V15, ts1, V16, ts2, V17, V18, V19, V20, V21, V22, V23, V24, bigint1, T_PK3, ts3, V25, ts4, decimal1, V26, V27, bigint8, ts5, V28, V29, V30, V31, V32, int1);
        retval = voltExecuteSQL();
    } catch (Exception exp) {
        System.out.println("Problem in run method of InsertT procedure");
        System.out.println("T_PK1 is " + T_PK1 + " T_PK2 is " + T_PK2);
    }
    return retval;
}
Also used : TimestampType(org.voltdb.types.TimestampType) ParseException(java.text.ParseException) VoltTable(org.voltdb.VoltTable) SimpleDateFormat(java.text.SimpleDateFormat) BigDecimal(java.math.BigDecimal) Date(java.util.Date) ParseException(java.text.ParseException)

Example 77 with VoltTable

use of org.voltdb.VoltTable in project voltdb by VoltDB.

the class ClientMoverEL method main.

public static void main(String[] args) {
    long numMoves = (long) Long.valueOf(args[0]);
    String serverList = args[1];
    long clientDurationSeconds = (long) Long.valueOf(args[2]);
    long loopPauseSeconds = (long) Long.valueOf(args[3]);
    m_logger.info(String.format("Executing %,d moves per transaction", numMoves));
    m_logger.info(String.format("Running for %,d second(s)", clientDurationSeconds));
    int num_partitions = 0;
    long playerId;
    long gameId;
    long socialId;
    long clientId;
    long visitTime;
    int intCounter;
    long longCounter;
    final org.voltdb.client.Client voltclient = ClientFactory.createClient();
    String[] voltServers = serverList.split(",");
    for (String thisServer : voltServers) {
        try {
            thisServer = thisServer.trim();
            m_logger.info(String.format("Connecting to server: %s", thisServer));
            voltclient.createConnection(thisServer, "program", "none");
        } catch (IOException e) {
            m_logger.error(e.toString());
            System.exit(-1);
        }
    }
    java.util.Random rand = new java.util.Random(0);
    long startTime = System.currentTimeMillis();
    long endTime = startTime + (1000l * clientDurationSeconds);
    long currentTime = startTime;
    // get the # of partitions in my cluster
    try {
        VoltTable[] vtPartitionInfo = voltclient.callProcedure("@Statistics", "partitioncount", 0l).getResults();
        num_partitions = (int) vtPartitionInfo[0].fetchRow(0).getLong(0);
        m_logger.info("System is running with " + num_partitions + " partition(s).");
    } catch (ProcCallException e) {
        m_logger.error("ProcCallException:");
        m_logger.error(e.toString());
    } catch (IOException e) {
        m_logger.error("IOException:");
        m_logger.error(e.toString());
        System.exit(-1);
    }
    boolean foundRows = true;
    boolean foundFullRowset = false;
    while (endTime > currentTime) {
        // do a single archive at each partition
        foundRows = false;
        foundFullRowset = false;
        long callTimeMillis = System.currentTimeMillis();
        try {
            for (longCounter = 0; longCounter < num_partitions; longCounter++) {
                try {
                    long callTimeBegin = System.currentTimeMillis();
                    VoltTable[] vtArchiveVisits = voltclient.callProcedure("ArchiveVisitsEL", longCounter, numMoves, callTimeMillis).getResults();
                    long callTimeEnd = System.currentTimeMillis();
                    int rowCount = (int) vtArchiveVisits[0].fetchRow(0).getLong(1);
                    if (rowCount > 0) {
                        // write out the rows
                        foundRows = true;
                        if (rowCount == numMoves) {
                            foundFullRowset = true;
                        }
                    }
                    String currentDate = new Date().toString();
                    m_logger.info(String.format("[%s] Ran archive on partition %d : archived %,d row(s) in %,d milliseconds", currentDate, longCounter, rowCount, (callTimeEnd - callTimeBegin)));
                } catch (ProcCallException e) {
                    m_logger.error("ProcCallException:");
                    m_logger.error(e.toString());
                } catch (NoConnectionsException e) {
                    m_logger.error("IOException:");
                    m_logger.error(e.toString());
                    System.exit(-1);
                }
            }
            if (!foundRows) {
                // no rows found
                m_logger.info("No rows found for this run.");
                // pause for 5 seconds
                m_logger.info(String.format("Pausing for %d seconds...", loopPauseSeconds));
                long pauseCurrentMillis = System.currentTimeMillis();
                long pauseEndMillis = pauseCurrentMillis + (loopPauseSeconds * 1000l);
                while (pauseCurrentMillis < pauseEndMillis) {
                    pauseCurrentMillis = System.currentTimeMillis();
                }
            } else if (!foundFullRowset) {
                // none of the rowsets were full (amount requested)
                // pause for given number seconds
                m_logger.info(String.format("No full rowsets found, pausing for %d seconds...", loopPauseSeconds));
                long pauseCurrentMillis = System.currentTimeMillis();
                long pauseEndMillis = pauseCurrentMillis + (loopPauseSeconds * 1000l);
                while (pauseCurrentMillis < pauseEndMillis) {
                    pauseCurrentMillis = System.currentTimeMillis();
                }
            }
        } catch (IOException e) {
            m_logger.error(e.toString());
            System.exit(-1);
        }
        currentTime = System.currentTimeMillis();
    }
    try {
        voltclient.drain();
    } catch (InterruptedException e) {
        m_logger.error(e.toString());
        System.exit(-1);
    } catch (NoConnectionsException e) {
        m_logger.error(e.toString());
        System.exit(-1);
    }
    try {
        voltclient.close();
    } catch (Exception e) {
        m_logger.error(e.toString());
        System.exit(-1);
    }
}
Also used : IOException(java.io.IOException) VoltTable(org.voltdb.VoltTable) Date(java.util.Date) ProcCallException(org.voltdb.client.ProcCallException) NoConnectionsException(org.voltdb.client.NoConnectionsException) IOException(java.io.IOException) NoConnectionsException(org.voltdb.client.NoConnectionsException) ProcCallException(org.voltdb.client.ProcCallException)

Example 78 with VoltTable

use of org.voltdb.VoltTable in project voltdb by VoltDB.

the class Eng866Client method parseStats.

static void parseStats(ClientResponse resp) {
    // Go ghetto for now and assume we're running on one host.
    VoltTable memory_stats = resp.getResults()[0];
    //System.out.println("mem stats: " + memory_stats);
    long rss = memory_stats.fetchRow(0).getLong("RSS");
    if (rss > m_highRss) {
        m_highRss = rss;
        m_highRssTime = System.currentTimeMillis();
    }
    long alloc_mem = 0;
    long used_mem = 0;
    alloc_mem += memory_stats.fetchRow(0).getLong("JAVAUSED");
    alloc_mem += memory_stats.fetchRow(0).getLong("TUPLEALLOCATED");
    alloc_mem += memory_stats.fetchRow(0).getLong("INDEXMEMORY");
    alloc_mem += memory_stats.fetchRow(0).getLong("POOLEDMEMORY");
    used_mem += memory_stats.fetchRow(0).getLong("JAVAUSED");
    used_mem += memory_stats.fetchRow(0).getLong("TUPLEDATA");
    used_mem += memory_stats.fetchRow(0).getLong("INDEXMEMORY");
    used_mem += memory_stats.fetchRow(0).getLong("STRINGMEMORY");
    if (alloc_mem > m_highAllocMem) {
        m_highAllocMem = alloc_mem;
        m_highAllocMemTime = System.currentTimeMillis();
    }
    if (used_mem > m_highUsedMem) {
        m_highUsedMem = used_mem;
        m_highUsedMemTime = System.currentTimeMillis();
    }
    System.out.println("CURRENT MEMORY TOTALS (USED, ALLOCATED, RSS):");
    System.out.println("CURRENT," + used_mem * 1000 + "," + alloc_mem * 1000 + "," + rss * 1000);
    Date blah = new Date(m_highUsedMemTime);
    System.out.println("LARGEST MEMORY USED: " + m_highUsedMem * 1000 + " at " + blah.toString());
    blah = new Date(m_highAllocMemTime);
    System.out.println("LARGEST MEMORY ALLOCATED: " + m_highAllocMem * 1000 + " at " + blah.toString());
    blah = new Date(m_highRssTime);
    System.out.println("LARGEST RSS: " + m_highRss * 1000 + " at " + blah.toString());
}
Also used : VoltTable(org.voltdb.VoltTable) Date(java.util.Date)

Example 79 with VoltTable

use of org.voltdb.VoltTable in project voltdb by VoltDB.

the class ExportBenchmark method waitForStreamedAllocatedMemoryZero.

/**
     * Checks the export table to make sure that everything has been successfully
     * processed.
     * @throws ProcCallException
     * @throws IOException
     * @throws InterruptedException
     */
public boolean waitForStreamedAllocatedMemoryZero() throws ProcCallException, IOException, InterruptedException {
    boolean passed = false;
    VoltTable stats = null;
    long ftime = 0;
    long st = System.currentTimeMillis();
    //Wait 10 mins only
    long end = st + (10 * 60 * 1000);
    while (true) {
        stats = client.callProcedure("@Statistics", "table", 0).getResults()[0];
        boolean passedThisTime = true;
        long ctime = System.currentTimeMillis();
        if (ctime > end) {
            System.out.println("Waited too long...");
            System.out.println(stats);
            break;
        }
        if (ctime - st > (3 * 60 * 1000)) {
            System.out.println(stats);
            st = System.currentTimeMillis();
        }
        long ts = 0;
        while (stats.advanceRow()) {
            String ttype = stats.getString("TABLE_TYPE");
            Long tts = stats.getLong("TIMESTAMP");
            //Get highest timestamp and watch it change
            if (tts > ts) {
                ts = tts;
            }
            if ("StreamedTable".equals(ttype)) {
                if (0 != stats.getLong("TUPLE_ALLOCATED_MEMORY")) {
                    passedThisTime = false;
                    System.out.println("Partition Not Zero.");
                    break;
                }
            }
        }
        if (passedThisTime) {
            if (ftime == 0) {
                ftime = ts;
                continue;
            }
            //we got 0 stats 2 times in row with diff highest timestamp.
            if (ftime != ts) {
                passed = true;
                break;
            }
            System.out.println("Passed but not ready to declare victory.");
        }
        Thread.sleep(5000);
    }
    System.out.println("Passed is: " + passed);
    System.out.println(stats);
    return passed;
}
Also used : AtomicLong(java.util.concurrent.atomic.AtomicLong) VoltTable(org.voltdb.VoltTable)

Example 80 with VoltTable

use of org.voltdb.VoltTable in project voltdb by VoltDB.

the class MatchChecks method getExportRowCount.

protected static long getExportRowCount(Client client) {
    // get the count of rows exported
    ClientResponse response = doAdHoc(client, "select sum(TOTAL_ROWS_EXPORTED) from exportcounts order by 1;");
    VoltTable[] countQueryResult = response.getResults();
    VoltTable data = countQueryResult[0];
    if (data.asScalarLong() == VoltType.NULL_BIGINT)
        return 0;
    return data.asScalarLong();
}
Also used : ClientResponse(org.voltdb.client.ClientResponse) VoltTable(org.voltdb.VoltTable)

Aggregations

VoltTable (org.voltdb.VoltTable)887 Client (org.voltdb.client.Client)497 ClientResponse (org.voltdb.client.ClientResponse)193 ProcCallException (org.voltdb.client.ProcCallException)144 IOException (java.io.IOException)100 VoltTableRow (org.voltdb.VoltTableRow)57 NoConnectionsException (org.voltdb.client.NoConnectionsException)52 ColumnInfo (org.voltdb.VoltTable.ColumnInfo)42 TimestampType (org.voltdb.types.TimestampType)37 BigDecimal (java.math.BigDecimal)30 ArrayList (java.util.ArrayList)27 Test (org.junit.Test)26 File (java.io.File)25 HashMap (java.util.HashMap)21 ClientResponseImpl (org.voltdb.ClientResponseImpl)20 Timestamp (java.sql.Timestamp)15 Date (java.util.Date)15 VoltDB (org.voltdb.VoltDB)15 DependencyPair (org.voltdb.DependencyPair)14 Configuration (org.voltdb.VoltDB.Configuration)14