public void open() throws IOException { if (isOpen) { return; // silently return } try { tbl = EagleConfigFactory.load().getHTable(this.table); } catch (RuntimeException ex) { throw new IOException(ex); } isOpen = true; }
@Override public void open() throws IOException { try{ tbl = EagleConfigFactory.load().getHTable(this.table); // LOGGER.info("HBase table " + table + " audo reflush is " + (tbl.isAutoFlush() ? "enabled" : "disabled")); }catch(Exception ex){ LOG.error("Cannot create htable", ex); throw new IOException(ex); } }
@Override public void open() throws IOException { try { tbl = EagleConfigFactory.load().getHTable(this.table); // LOGGER.info("HBase table " + table + " audo reflush is " + (tbl.isAutoFlush() ? "enabled" : // "disabled")); } catch (Exception ex) { LOG.error("Cannot create htable", ex); throw new IOException(ex); } }
@Override public void open() throws IOException { try { tbl = EagleConfigFactory.load().getHTable(this.table); } catch (RuntimeException ex) { throw new IOException(ex); } }
@Override public void open() throws IOException { try{ tbl = EagleConfigFactory.load().getHTable(this.table); }catch(RuntimeException ex){ throw new IOException(ex); } }
public long getTimestampFromDate(String dateStr) throws ParseException { SimpleDateFormat sdf = new SimpleDateFormat(DATE_FORMAT_PATTERN); sdf.setTimeZone(EagleConfigFactory.load().getTimeZone()); Date d = sdf.parse(dateStr); return d.getTime(); }
public void open() throws IOException { if (isOpen) return; // silently return try { tbl = EagleConfigFactory.load().getHTable(this.table); } catch (RuntimeException ex) { throw new IOException(ex); } isOpen = true; }
/** * Check if audit is required based on the service names and audit configuration. * @param serviceName: Name of the service call. * @return */ private boolean isAuditingRequired (String serviceName) { if (EagleConfigFactory.load().isServiceAuditingEnabled() // As per jira EAGLE-47, HBase operation level audit is done only for Policy, Site and DataSource definitions. && ("AlertDefinitionService".equals(serviceName) || "AlertDataSourceService".equals(serviceName))) { return true; } return false; }
/** * Check if audit is required based on the service names and audit configuration. * * @param serviceName: Name of the service call. * @return */ private boolean isAuditingRequired(String serviceName) { if (EagleConfigFactory.load().isServiceAuditingEnabled() // As per jira EAGLE-47, HBase operation level audit is done only for Policy, Site and DataSource definitions. && ("AlertDefinitionService".equals(serviceName) || "AlertDataSourceService".equals(serviceName))) { return true; } return false; }
@GET @Produces(MediaType.APPLICATION_JSON) public EagleServiceSelfCheckAPIEntity selfCheck(){ EagleServiceSelfCheckAPIEntity entity = new EagleServiceSelfCheckAPIEntity(); entity.setHbaseZookeeperQuorum(EagleConfigFactory.load().getZKQuorum()); entity.setHbaseZookeeperClientPort(EagleConfigFactory.load().getZKPort()); entity.setEnv(EagleConfigFactory.load().getEnv()); return entity; } }
@GET @Produces(MediaType.APPLICATION_JSON) public EagleServiceSelfCheckAPIEntity selfCheck(){ EagleServiceSelfCheckAPIEntity entity = new EagleServiceSelfCheckAPIEntity(); entity.setHBaseZookeeperQuorum(EagleConfigFactory.load().getZKQuorum()); entity.setHBaseZookeeperClientPort(EagleConfigFactory.load().getZKPort()); entity.setEnv(EagleConfigFactory.load().getEnv()); return entity; } }
/** * get storage class by type configured as eagle.storage.type from eagle configuration: config.properties * * @return DataStorage instance * @throws IllegalDataStorageTypeException */ public static synchronized DataStorage getDataStorageByEagleConfig(boolean cache) throws IllegalDataStorageTypeException { String storageType = EagleConfigFactory.load().getStorageType(); if (!cache) { return newDataStorage(storageType); } if (singletonStorageInstance == null) { if (storageType == null) { LOG.error(EAGLE_STORAGE_TYPE + " is null, trying default data storage: " + DEFAULT_DATA_STORAGE_TYPE); storageType = DEFAULT_DATA_STORAGE_TYPE; } singletonStorageInstance = newDataStorage(storageType); } return singletonStorageInstance; }
@Override public void open() throws IOException { if (isOpen) { return; // silently return } try { tbl = EagleConfigFactory.load().getHTable(indexDef.getEntityDefinition().getTable()); } catch (RuntimeException ex) { throw new IOException(ex); } currentScanIndex = 0; openNewScan(); fillResults(); }
@Override public void open() throws IOException { if (isOpen) return; // silently return try { tbl = EagleConfigFactory.load().getHTable(indexDef.getEntityDefinition().getTable()); } catch (RuntimeException ex) { throw new IOException(ex); } currentScanIndex = 0; openNewScan(); fillResults(); }
private List<Scan> buildScans() { final ArrayList<Scan> result = new ArrayList<Scan>(indexRowkeys.size()); for (byte[] rowkey : indexRowkeys) { Scan s = new Scan(); s.setStartRow(rowkey); // In rowkey the tag key/value is sorted by the hash code of the key, so MAX_TAG_VALUE_BYTES is // enough as the end key final byte[] stopRowkey = ByteUtil.concat(rowkey, MAX_TAG_VALUE_BYTES); s.setStopRow(stopRowkey); // TODO the # of cached rows should be minimum of (pagesize and 100) int cs = EagleConfigFactory.load().getHBaseClientScanCacheSize(); s.setCaching(cs); // TODO not optimized for all applications s.setCacheBlocks(true); // scan specified columnfamily for all qualifiers s.addFamily(indexDef.getEntityDefinition().getColumnFamily().getBytes()); result.add(s); } return result; }
static long createTimeStamp(int year, int month, int date, int hourOfDay, int minute, int second) { GregorianCalendar gc = new GregorianCalendar(); gc.clear(); gc.set(year, month, date, hourOfDay, minute, second); gc.setTimeZone(EagleConfigFactory.load().getTimeZone()); return gc.getTime().getTime(); }
public void setUp(){ client = new EagleServiceClientImpl("localhost", EagleConfigFactory.load().getServicePort()); }
@Before public void setUp() { startTime = System.currentTimeMillis(); try { rowkeys = prepareData(num); } catch (Exception e) { e.printStackTrace(); Assert.fail(e.getMessage()); } endTime = System.currentTimeMillis(); table = EagleConfigFactory.load().getHTable("unittest"); client = new AggregateClientImpl(); scan = new Scan(); scan.setCaching(200); ListQueryCompiler compiler = null; try { compiler = new ListQueryCompiler("TestLogAPIEntity[@cluster=\"test4UT\" and @datacenter=\"dc1\"]{@field1,@field2}"); } catch (Exception e) { Assert.fail(e.getMessage()); } scan.setFilter(compiler.filter()); }
@Before public void setUp() throws IllegalAccessException, InstantiationException { ed = EntityDefinitionManager.getEntityDefinitionByEntityClass(TestTimeSeriesAPIEntity.class); table = EagleConfigFactory.load().getHTable("unittest"); startTime = System.currentTimeMillis(); try { rowkeys = prepareData(1000); } catch (Exception e) { e.printStackTrace(); Assert.fail(e.getMessage()); } endTime = System.currentTimeMillis(); client = new AggregateClientImpl(); scan = new Scan(); ListQueryCompiler compiler = null; try { compiler = new ListQueryCompiler("TestTimeSeriesAPIEntity[@cluster=\"test4UT\" and @datacenter = \"dc1\"]{@field1,@field2}"); } catch (Exception e) { Assert.fail(e.getMessage()); } scan.setFilter(compiler.filter()); // scan.setStartRow(EagleBase64Wrapper.decode(rowkeys.get(0))); // scan.setStopRow(EagleBase64Wrapper.decode(rowkeys.get(rowkeys.size()-1))); }
/** * Just compiling passed is ok */ //@Test @SuppressWarnings("unused") public void testCreate() throws IOException, EagleServiceClientException, IllegalAccessException, InstantiationException { EntityDefinition entityDefinition = EntityDefinitionManager.getEntityDefinitionByEntityClass(GenericMetricEntity.class); hbase.createTable(entityDefinition.getTable(), entityDefinition.getColumnFamily()); client = new EagleServiceClientImpl("localhost", EagleConfigFactory.load().getServicePort()); List<GenericMetricEntity> metricEntityList = new ArrayList<GenericMetricEntity>(); GenericServiceAPIResponseEntity<String> unTypedResponse = client.create(metricEntityList); GenericServiceAPIResponseEntity<String> weakTypedResponse = client.create(metricEntityList,GenericMetricEntity.GENERIC_METRIC_SERVICE); GenericServiceAPIResponseEntity<String> strongTypedResponse = client.create(metricEntityList,GenericMetricEntity.class); GenericServiceAPIResponseEntity<GenericMetricEntity> weakTypedSearchResponse = client.search("").send(); if(weakTypedSearchResponse!=null) { Class<GenericMetricEntity> typedClazz = weakTypedSearchResponse.getType(); List<GenericMetricEntity> typedEntities = weakTypedSearchResponse.getObj(); } }