use of org.apache.metron.hbase.mock.MockHBaseTableProvider 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());
}
use of org.apache.metron.hbase.mock.MockHBaseTableProvider 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());
}
use of org.apache.metron.hbase.mock.MockHBaseTableProvider in project metron by apache.
the class HBaseDaoIntegrationTest method startHBase.
@BeforeEach
public void startHBase() {
AccessConfig accessConfig = new AccessConfig();
accessConfig.setMaxSearchResults(1000);
accessConfig.setMaxSearchGroups(1000);
accessConfig.setGlobalConfigSupplier(() -> new HashMap<String, Object>() {
{
put(HBASE_TABLE, TABLE_NAME);
put(HBASE_CF, COLUMN_FAMILY);
}
});
MockHBaseTableProvider.addToCache(TABLE_NAME, COLUMN_FAMILY);
accessConfig.setTableProvider(new MockHBaseTableProvider());
hbaseDao = new HBaseDao();
hbaseDao.init(accessConfig);
}
Aggregations