Search in sources :

Example 31 with TraceScope

use of org.apache.htrace.core.TraceScope in project YCSB by brianfrankcooper.

the class DBWrapper method init.

/**
   * Initialize any state for this DB.
   * Called once per DB instance; there is one DB instance per client thread.
   */
public void init() throws DBException {
    try (final TraceScope span = tracer.newScope(scopeStringInit)) {
        db.init();
        this.reportLatencyForEachError = Boolean.parseBoolean(getProperties().getProperty(REPORT_LATENCY_FOR_EACH_ERROR_PROPERTY, REPORT_LATENCY_FOR_EACH_ERROR_PROPERTY_DEFAULT));
        if (!reportLatencyForEachError) {
            String latencyTrackedErrorsProperty = getProperties().getProperty(LATENCY_TRACKED_ERRORS_PROPERTY, null);
            if (latencyTrackedErrorsProperty != null) {
                this.latencyTrackedErrors = new HashSet<String>(Arrays.asList(latencyTrackedErrorsProperty.split(",")));
            }
        }
        System.err.println("DBWrapper: report latency for each error is " + this.reportLatencyForEachError + " and specific error codes to track" + " for latency are: " + this.latencyTrackedErrors.toString());
    }
}
Also used : TraceScope(org.apache.htrace.core.TraceScope)

Example 32 with TraceScope

use of org.apache.htrace.core.TraceScope in project YCSB by brianfrankcooper.

the class DBWrapper method cleanup.

/**
   * Cleanup any state for this DB.
   * Called once per DB instance; there is one DB instance per client thread.
   */
public void cleanup() throws DBException {
    try (final TraceScope span = tracer.newScope(scopeStringCleanup)) {
        long ist = measurements.getIntendedtartTimeNs();
        long st = System.nanoTime();
        db.cleanup();
        long en = System.nanoTime();
        measure("CLEANUP", Status.OK, ist, st, en);
    }
}
Also used : TraceScope(org.apache.htrace.core.TraceScope)

Example 33 with TraceScope

use of org.apache.htrace.core.TraceScope in project YCSB by brianfrankcooper.

the class Client method initWorkload.

private static void initWorkload(Properties props, Thread warningthread, Workload workload, Tracer tracer) {
    try {
        try (final TraceScope span = tracer.newScope(CLIENT_WORKLOAD_INIT_SPAN)) {
            workload.init(props);
            warningthread.interrupt();
        }
    } catch (WorkloadException e) {
        e.printStackTrace();
        e.printStackTrace(System.out);
        System.exit(0);
    }
}
Also used : TraceScope(org.apache.htrace.core.TraceScope)

Example 34 with TraceScope

use of org.apache.htrace.core.TraceScope in project YCSB by brianfrankcooper.

the class Client method initDb.

private static List<ClientThread> initDb(String dbname, Properties props, int threadcount, double targetperthreadperms, Workload workload, Tracer tracer, CountDownLatch completeLatch) {
    boolean initFailed = false;
    boolean dotransactions = Boolean.valueOf(props.getProperty(DO_TRANSACTIONS_PROPERTY, String.valueOf(true)));
    final List<ClientThread> clients = new ArrayList<>(threadcount);
    try (final TraceScope span = tracer.newScope(CLIENT_INIT_SPAN)) {
        int opcount;
        if (dotransactions) {
            opcount = Integer.parseInt(props.getProperty(OPERATION_COUNT_PROPERTY, "0"));
        } else {
            if (props.containsKey(INSERT_COUNT_PROPERTY)) {
                opcount = Integer.parseInt(props.getProperty(INSERT_COUNT_PROPERTY, "0"));
            } else {
                opcount = Integer.parseInt(props.getProperty(RECORD_COUNT_PROPERTY, DEFAULT_RECORD_COUNT));
            }
        }
        for (int threadid = 0; threadid < threadcount; threadid++) {
            DB db;
            try {
                db = DBFactory.newDB(dbname, props, tracer);
            } catch (UnknownDBException e) {
                System.out.println("Unknown DB " + dbname);
                initFailed = true;
                break;
            }
            int threadopcount = opcount / threadcount;
            // ensure correct number of operations, in case opcount is not a multiple of threadcount
            if (threadid < opcount % threadcount) {
                ++threadopcount;
            }
            ClientThread t = new ClientThread(db, dotransactions, workload, props, threadopcount, targetperthreadperms, completeLatch);
            clients.add(t);
        }
        if (initFailed) {
            System.err.println("Error initializing datastore bindings.");
            System.exit(0);
        }
    }
    return clients;
}
Also used : TraceScope(org.apache.htrace.core.TraceScope)

Example 35 with TraceScope

use of org.apache.htrace.core.TraceScope in project YCSB by brianfrankcooper.

the class DBWrapper method update.

/**
   * Update a record in the database. Any field/value pairs in the specified values HashMap will be written into the
   * record with the specified record key, overwriting any existing values with the same field name.
   *
   * @param table The name of the table
   * @param key The record key of the record to write.
   * @param values A HashMap of field/value pairs to update in the record
   * @return The result of the operation.
   */
public Status update(String table, String key, HashMap<String, ByteIterator> values) {
    try (final TraceScope span = tracer.newScope(scopeStringUpdate)) {
        long ist = measurements.getIntendedtartTimeNs();
        long st = System.nanoTime();
        Status res = db.update(table, key, values);
        long en = System.nanoTime();
        measure("UPDATE", res, ist, st, en);
        measurements.reportStatus("UPDATE", res);
        return res;
    }
}
Also used : TraceScope(org.apache.htrace.core.TraceScope)

Aggregations

TraceScope (org.apache.htrace.core.TraceScope)54 IOException (java.io.IOException)11 InterruptedIOException (java.io.InterruptedIOException)7 MultipleIOException (org.apache.hadoop.io.MultipleIOException)6 RemoteException (org.apache.hadoop.ipc.RemoteException)5 FileNotFoundException (java.io.FileNotFoundException)4 SnapshotAccessControlException (org.apache.hadoop.hdfs.protocol.SnapshotAccessControlException)4 UnresolvedPathException (org.apache.hadoop.hdfs.protocol.UnresolvedPathException)4 AccessControlException (org.apache.hadoop.security.AccessControlException)4 ClosedChannelException (java.nio.channels.ClosedChannelException)3 FileAlreadyExistsException (org.apache.hadoop.fs.FileAlreadyExistsException)3 ParentNotDirectoryException (org.apache.hadoop.fs.ParentNotDirectoryException)3 DSQuotaExceededException (org.apache.hadoop.hdfs.protocol.DSQuotaExceededException)3 NSQuotaExceededException (org.apache.hadoop.hdfs.protocol.NSQuotaExceededException)3 QuotaByStorageTypeExceededException (org.apache.hadoop.hdfs.protocol.QuotaByStorageTypeExceededException)3 Tracer (org.apache.htrace.core.Tracer)3 ByteBuffer (java.nio.ByteBuffer)2 List (java.util.List)2 EventBatch (org.apache.hadoop.hdfs.inotify.EventBatch)2 DatanodeInfo (org.apache.hadoop.hdfs.protocol.DatanodeInfo)2