Search in sources :

Example 1 with ValueOnlyColumnBuilder

use of org.apache.metron.profiler.hbase.ValueOnlyColumnBuilder in project metron by apache.

the class HBaseProfilerClientTest method setup.

@BeforeEach
public void setup() {
    provider = new MockHBaseTableProvider();
    executor = new DefaultStellarStatefulExecutor();
    MockHBaseTableProvider.addToCache(tableName, columnFamily);
    // writes values to be read during testing
    long periodDurationMillis = periodUnits.toMillis(periodDuration);
    RowKeyBuilder rowKeyBuilder = new SaltyRowKeyBuilder();
    ColumnBuilder columnBuilder = new ValueOnlyColumnBuilder(columnFamily);
    profileWriter = new ProfileWriter(rowKeyBuilder, columnBuilder, provider, periodDurationMillis, tableName, null);
    client = new HBaseProfilerClient(provider, rowKeyBuilder, columnBuilder, periodDurationMillis, tableName, null);
}
Also used : SaltyRowKeyBuilder(org.apache.metron.profiler.hbase.SaltyRowKeyBuilder) MockHBaseTableProvider(org.apache.metron.hbase.mock.MockHBaseTableProvider) ValueOnlyColumnBuilder(org.apache.metron.profiler.hbase.ValueOnlyColumnBuilder) DefaultStellarStatefulExecutor(org.apache.metron.stellar.common.DefaultStellarStatefulExecutor) SaltyRowKeyBuilder(org.apache.metron.profiler.hbase.SaltyRowKeyBuilder) RowKeyBuilder(org.apache.metron.profiler.hbase.RowKeyBuilder) ColumnBuilder(org.apache.metron.profiler.hbase.ColumnBuilder) ValueOnlyColumnBuilder(org.apache.metron.profiler.hbase.ValueOnlyColumnBuilder) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 2 with ValueOnlyColumnBuilder

use of org.apache.metron.profiler.hbase.ValueOnlyColumnBuilder in project metron by apache.

the class ProfilerIntegrationTest method setupBeforeClass.

@BeforeClass
public static void setupBeforeClass() throws UnableToStartException {
    columnBuilder = new ValueOnlyColumnBuilder(columnFamily);
    // storm topology properties
    final Properties topologyProperties = new Properties() {

        {
            // storm settings
            setProperty("profiler.workers", "1");
            setProperty("profiler.executors", "0");
            setProperty("storm.auto.credentials", "[]");
            setProperty("topology.auto-credentials", "[]");
            setProperty("topology.message.timeout.secs", "60");
            setProperty("topology.max.spout.pending", "100000");
            // kafka settings
            setProperty("profiler.input.topic", inputTopic);
            setProperty("profiler.output.topic", outputTopic);
            setProperty("kafka.start", "UNCOMMITTED_EARLIEST");
            setProperty("kafka.security.protocol", "PLAINTEXT");
            // hbase settings
            setProperty("profiler.hbase.salt.divisor", Integer.toString(saltDivisor));
            setProperty("profiler.hbase.table", tableName);
            setProperty("profiler.hbase.column.family", columnFamily);
            setProperty("profiler.hbase.batch", "10");
            setProperty("profiler.hbase.flush.interval.seconds", "1");
            setProperty("hbase.provider.impl", "" + MockHBaseTableProvider.class.getName());
            // profile settings
            setProperty("profiler.period.duration", Long.toString(periodDurationMillis));
            setProperty("profiler.period.duration.units", "MILLISECONDS");
            setProperty("profiler.ttl", Long.toString(profileTimeToLiveMillis));
            setProperty("profiler.ttl.units", "MILLISECONDS");
            setProperty("profiler.window.duration", Long.toString(windowDurationMillis));
            setProperty("profiler.window.duration.units", "MILLISECONDS");
            setProperty("profiler.window.lag", Long.toString(windowLagMillis));
            setProperty("profiler.window.lag.units", "MILLISECONDS");
            setProperty("profiler.max.routes.per.bolt", Long.toString(maxRoutesPerBolt));
        }
    };
    // create the mock table
    profilerTable = (MockHTable) MockHBaseTableProvider.addToCache(tableName, columnFamily);
    zkComponent = getZKServerComponent(topologyProperties);
    // create the input and output topics
    kafkaComponent = getKafkaComponent(topologyProperties, Arrays.asList(new KafkaComponent.Topic(inputTopic, 1), new KafkaComponent.Topic(outputTopic, 1)));
    // upload profiler configuration to zookeeper
    configUploadComponent = new ConfigUploadComponent().withTopologyProperties(topologyProperties);
    // load flux definition for the profiler topology
    fluxComponent = new FluxTopologyComponent.Builder().withTopologyLocation(new File(FLUX_PATH)).withTopologyName("profiler").withTopologyProperties(topologyProperties).build();
    // start all components
    runner = new ComponentRunner.Builder().withComponent("zk", zkComponent).withComponent("kafka", kafkaComponent).withComponent("config", configUploadComponent).withComponent("storm", fluxComponent).withMillisecondsBetweenAttempts(15000).withNumRetries(10).withCustomShutdownOrder(new String[] { "storm", "config", "kafka", "zk" }).build();
    runner.start();
}
Also used : KafkaComponent(org.apache.metron.integration.components.KafkaComponent) ValueOnlyColumnBuilder(org.apache.metron.profiler.hbase.ValueOnlyColumnBuilder) ComponentRunner(org.apache.metron.integration.ComponentRunner) Properties(java.util.Properties) FluxTopologyComponent(org.apache.metron.integration.components.FluxTopologyComponent) File(java.io.File) BeforeClass(org.junit.BeforeClass)

Example 3 with ValueOnlyColumnBuilder

use of org.apache.metron.profiler.hbase.ValueOnlyColumnBuilder in project metron by apache.

the class GetProfile method getColumnBuilder.

/**
 * Creates the ColumnBuilder to use in accessing the profile data.
 * @param global The global configuration.
 */
private ColumnBuilder getColumnBuilder(Map<String, Object> global) {
    ColumnBuilder columnBuilder;
    String columnFamily = PROFILER_COLUMN_FAMILY.get(global, String.class);
    columnBuilder = new ValueOnlyColumnBuilder(columnFamily);
    return columnBuilder;
}
Also used : ValueOnlyColumnBuilder(org.apache.metron.profiler.hbase.ValueOnlyColumnBuilder) ColumnBuilder(org.apache.metron.profiler.hbase.ColumnBuilder) ValueOnlyColumnBuilder(org.apache.metron.profiler.hbase.ValueOnlyColumnBuilder)

Example 4 with ValueOnlyColumnBuilder

use of org.apache.metron.profiler.hbase.ValueOnlyColumnBuilder in project metron by apache.

the class GetProfileTest method setup.

/**
 * This method sets up the configuration context for both writing profile data
 * (using profileWriter to mock the complex process of what the Profiler topology
 * actually does), and then reading that profile data (thereby testing the PROFILE_GET
 * Stellar client implemented in GetProfile).
 *
 * It runs at @BeforeEach time, and sets testclass global variables used by the writers and readers.
 * The various writers and readers are in each test case, not here.
 *
 * @return void
 */
@BeforeEach
public void setup() {
    state = new HashMap<>();
    final Table table = MockHBaseTableProvider.addToCache(tableName, columnFamily);
    // used to write values to be read during testing
    long periodDurationMillis = TimeUnit.MINUTES.toMillis(15);
    RowKeyBuilder rowKeyBuilder = new SaltyRowKeyBuilder();
    ColumnBuilder columnBuilder = new ValueOnlyColumnBuilder(columnFamily);
    profileWriter = new ProfileWriter(rowKeyBuilder, columnBuilder, new MockHBaseTableProvider(), periodDurationMillis, tableName, null);
    // global properties
    Map<String, Object> global = new HashMap<String, Object>() {

        {
            put(PROFILER_HBASE_TABLE.getKey(), tableName);
            put(PROFILER_COLUMN_FAMILY.getKey(), columnFamily);
            put(PROFILER_HBASE_TABLE_PROVIDER.getKey(), MockHBaseTableProvider.class.getName());
            put(PROFILER_PERIOD.getKey(), Long.toString(periodDuration));
            put(PROFILER_PERIOD_UNITS.getKey(), periodUnits.toString());
            put(PROFILER_SALT_DIVISOR.getKey(), Integer.toString(saltDivisor));
        }
    };
    // create the stellar execution environment
    executor = new DefaultStellarStatefulExecutor(new SimpleFunctionResolver().withClass(GetProfile.class).withClass(FixedLookback.class), new Context.Builder().with(Context.Capabilities.GLOBAL_CONFIG, () -> global).build());
}
Also used : Table(org.apache.hadoop.hbase.client.Table) SaltyRowKeyBuilder(org.apache.metron.profiler.hbase.SaltyRowKeyBuilder) MockHBaseTableProvider(org.apache.metron.hbase.mock.MockHBaseTableProvider) SaltyRowKeyBuilder(org.apache.metron.profiler.hbase.SaltyRowKeyBuilder) ColumnBuilder(org.apache.metron.profiler.hbase.ColumnBuilder) ValueOnlyColumnBuilder(org.apache.metron.profiler.hbase.ValueOnlyColumnBuilder) RowKeyBuilder(org.apache.metron.profiler.hbase.RowKeyBuilder) SaltyRowKeyBuilder(org.apache.metron.profiler.hbase.SaltyRowKeyBuilder) RowKeyBuilder(org.apache.metron.profiler.hbase.RowKeyBuilder) ProfileWriter(org.apache.metron.profiler.client.ProfileWriter) ValueOnlyColumnBuilder(org.apache.metron.profiler.hbase.ValueOnlyColumnBuilder) DefaultStellarStatefulExecutor(org.apache.metron.stellar.common.DefaultStellarStatefulExecutor) ColumnBuilder(org.apache.metron.profiler.hbase.ColumnBuilder) ValueOnlyColumnBuilder(org.apache.metron.profiler.hbase.ValueOnlyColumnBuilder) SimpleFunctionResolver(org.apache.metron.stellar.dsl.functions.resolver.SimpleFunctionResolver) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 5 with ValueOnlyColumnBuilder

use of org.apache.metron.profiler.hbase.ValueOnlyColumnBuilder in project metron by apache.

the class VerboseProfileTest method setup.

@BeforeEach
public void setup() {
    state = new HashMap<>();
    final Table table = MockHBaseTableProvider.addToCache(tableName, columnFamily);
    TableProvider provider = new MockHBaseTableProvider();
    // used to write values to be read during testing
    long periodDurationMillis = TimeUnit.MINUTES.toMillis(15);
    RowKeyBuilder rowKeyBuilder = new SaltyRowKeyBuilder();
    ColumnBuilder columnBuilder = new ValueOnlyColumnBuilder(columnFamily);
    profileWriter = new ProfileWriter(rowKeyBuilder, columnBuilder, provider, periodDurationMillis, tableName, null);
    // global properties
    globals = new HashMap<String, Object>() {

        {
            put(PROFILER_HBASE_TABLE.getKey(), tableName);
            put(PROFILER_COLUMN_FAMILY.getKey(), columnFamily);
            put(PROFILER_HBASE_TABLE_PROVIDER.getKey(), MockHBaseTableProvider.class.getName());
            put(PROFILER_PERIOD.getKey(), Long.toString(periodDuration));
            put(PROFILER_PERIOD_UNITS.getKey(), periodUnits.toString());
            put(PROFILER_SALT_DIVISOR.getKey(), Integer.toString(saltDivisor));
        }
    };
    // create the stellar execution environment
    executor = new DefaultStellarStatefulExecutor(new SimpleFunctionResolver().withClass(VerboseProfile.class).withClass(FixedLookback.class), new Context.Builder().with(Context.Capabilities.GLOBAL_CONFIG, () -> globals).build());
}
Also used : Table(org.apache.hadoop.hbase.client.Table) SaltyRowKeyBuilder(org.apache.metron.profiler.hbase.SaltyRowKeyBuilder) MockHBaseTableProvider(org.apache.metron.hbase.mock.MockHBaseTableProvider) SaltyRowKeyBuilder(org.apache.metron.profiler.hbase.SaltyRowKeyBuilder) ColumnBuilder(org.apache.metron.profiler.hbase.ColumnBuilder) ValueOnlyColumnBuilder(org.apache.metron.profiler.hbase.ValueOnlyColumnBuilder) RowKeyBuilder(org.apache.metron.profiler.hbase.RowKeyBuilder) VerboseProfile(org.apache.metron.profiler.client.stellar.VerboseProfile) SaltyRowKeyBuilder(org.apache.metron.profiler.hbase.SaltyRowKeyBuilder) RowKeyBuilder(org.apache.metron.profiler.hbase.RowKeyBuilder) TableProvider(org.apache.metron.hbase.TableProvider) MockHBaseTableProvider(org.apache.metron.hbase.mock.MockHBaseTableProvider) ProfileWriter(org.apache.metron.profiler.client.ProfileWriter) ValueOnlyColumnBuilder(org.apache.metron.profiler.hbase.ValueOnlyColumnBuilder) DefaultStellarStatefulExecutor(org.apache.metron.stellar.common.DefaultStellarStatefulExecutor) ColumnBuilder(org.apache.metron.profiler.hbase.ColumnBuilder) ValueOnlyColumnBuilder(org.apache.metron.profiler.hbase.ValueOnlyColumnBuilder) SimpleFunctionResolver(org.apache.metron.stellar.dsl.functions.resolver.SimpleFunctionResolver) BeforeEach(org.junit.jupiter.api.BeforeEach)

Aggregations

ValueOnlyColumnBuilder (org.apache.metron.profiler.hbase.ValueOnlyColumnBuilder)6 ColumnBuilder (org.apache.metron.profiler.hbase.ColumnBuilder)5 RowKeyBuilder (org.apache.metron.profiler.hbase.RowKeyBuilder)4 SaltyRowKeyBuilder (org.apache.metron.profiler.hbase.SaltyRowKeyBuilder)4 MockHBaseTableProvider (org.apache.metron.hbase.mock.MockHBaseTableProvider)3 DefaultStellarStatefulExecutor (org.apache.metron.stellar.common.DefaultStellarStatefulExecutor)3 BeforeEach (org.junit.jupiter.api.BeforeEach)3 Table (org.apache.hadoop.hbase.client.Table)2 ProfileWriter (org.apache.metron.profiler.client.ProfileWriter)2 SimpleFunctionResolver (org.apache.metron.stellar.dsl.functions.resolver.SimpleFunctionResolver)2 File (java.io.File)1 Properties (java.util.Properties)1 Random (java.util.Random)1 Configuration (org.apache.hadoop.conf.Configuration)1 HBaseConfiguration (org.apache.hadoop.hbase.HBaseConfiguration)1 HTableProvider (org.apache.metron.hbase.HTableProvider)1 TableProvider (org.apache.metron.hbase.TableProvider)1 ComponentRunner (org.apache.metron.integration.ComponentRunner)1 FluxTopologyComponent (org.apache.metron.integration.components.FluxTopologyComponent)1 KafkaComponent (org.apache.metron.integration.components.KafkaComponent)1