blob: 9c1fa8593d1368c5f84bd76ebbe87a084c1432dc [file] [log] [blame]
/*
* Copyright (c) 2014 DataTorrent, Inc. ALL Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.datatorrent.benchmark.accumulo;
import org.apache.accumulo.core.data.Mutation;
import org.apache.hadoop.conf.Configuration;
import com.datatorrent.api.DAG;
import com.datatorrent.api.StreamingApplication;
import com.datatorrent.contrib.accumulo.AbstractAccumuloOutputOperator;
import com.datatorrent.contrib.accumulo.AccumuloRowTupleGenerator;
import com.datatorrent.contrib.accumulo.AccumuloTestHelper;
import com.datatorrent.contrib.accumulo.AccumuloTuple;
/**
* BenchMark Results
* -----------------
* The operator operates at 30,000 tuples/sec with the following configuration
*
* Container memory size=1G
* Accumulo Max Memory=2G
* Accumulo number of write threads=1
* CPU=Intel(R) Core(TM) i7-4500U CPU @ 1.80 GHz 2.40 Ghz
*
* @since 1.0.4
*/
public class AccumuloApp implements StreamingApplication {
@Override
public void populateDAG(DAG dag, Configuration conf) {
AccumuloTestHelper.getConnector();
AccumuloTestHelper.clearTable();
dag.setAttribute(DAG.APPLICATION_NAME, "AccumuloOutputTest");
AccumuloRowTupleGenerator rtg = dag.addOperator("tuplegenerator",AccumuloRowTupleGenerator.class);
TestAccumuloOutputOperator taop = dag.addOperator("testaccumulooperator", TestAccumuloOutputOperator.class);
dag.addStream("ss", rtg.outputPort, taop.input);
com.datatorrent.api.Attribute.AttributeMap attributes = dag.getAttributes();
taop.getStore().setTableName("tab1");
taop.getStore().setZookeeperHost("127.0.0.1");
taop.getStore().setInstanceName("instance");
taop.getStore().setUserName("root");
taop.getStore().setPassword("pass");
}
public static class TestAccumuloOutputOperator extends AbstractAccumuloOutputOperator<AccumuloTuple> {
@Override
public Mutation operationMutation(AccumuloTuple t) {
Mutation mutation = new Mutation(t.getRow().getBytes());
mutation.put(t.getColFamily().getBytes(),t.getColName().getBytes(),t.getColValue().getBytes());
return mutation;
}
}
}