@Override public GenericServiceAPIResponseEntity<String> call() throws Exception { return client.create(entities,serviceName); } });
@Override public GenericServiceAPIResponseEntity<String> call() throws Exception { return client.create(entities,entityClass); } });
@Override public GenericServiceAPIResponseEntity<String> call() throws Exception { return client.create(entities,entityClass); } });
@Override public GenericServiceAPIResponseEntity<String> call() throws Exception { return client.create(entities,serviceName); } });
@Override public GenericServiceAPIResponseEntity<String> call() throws Exception { return client.create(entities,entityClass); } });
@Override public GenericServiceAPIResponseEntity<String> call() throws Exception { return client.create(entities); } });
@Override public GenericServiceAPIResponseEntity<String> call() throws Exception { return client.create(entities,entityClass); } });
@Override public GenericServiceAPIResponseEntity<String> call() throws Exception { return client.create(entities); } });
private void flush(Map<String, GenericMetricEntity> appMetrics, List<YarnAppAPIEntity> acceptedApps) { List<TaggedLogAPIEntity> entities = new ArrayList<>(); if (appMetrics != null && !appMetrics.isEmpty()) { LOG.info("crawled {} running app metrics", appMetrics.size()); entities.addAll(appMetrics.values()); } if (acceptedApps != null && !acceptedApps.isEmpty()) { LOG.info("crawled {} accepted apps", acceptedApps.size()); //entities.addAll(acceptedApps); } try { client.create(entities); LOG.info("Successfully create {} metrics", entities.size()); } catch (Exception e) { LOG.error("Fail to create {} metrics due to {}", entities.size(), e.getMessage(), e); } }
@Override public void onAlert(AlertStreamEvent event) throws Exception { List<AlertStreamEvent> eventList = this.dedup(event); if (eventList == null || eventList.isEmpty()) { return; } List<AlertEntity> alertEvents = new ArrayList<>(); for (AlertStreamEvent e : eventList) { alertEvents.add(convertAlertEvent(e)); } client.create(alertEvents, AlertConstants.ALERT_SERVICE_ENDPOINT_NAME); }
private void writeEntities(List<TaggedLogAPIEntity> entities, DataType dataType, DataSource dataSource) { try { GenericServiceAPIResponseEntity response = client.create(entities); if (!response.isSuccess()) { LOG.error("Got exception from eagle service: " + response.getException()); } else { LOG.info("Successfully wrote {} items of {} for {}", entities.size(), dataType, dataSource); } } catch (Exception e) { LOG.error("cannot create {} entities", entities.size(), e); } entities.clear(); } }
public void flush() throws IOException, EagleServiceClientException { if(this.entityBucket.size() == 0 && LOG.isDebugEnabled()){ LOG.debug("No entities to flush"); return; } LOG.info("Writing "+this.entityBucket.size()+" entities"); GenericServiceAPIResponseEntity<String> response = this.client.create(this.entityBucket); if(!response.isSuccess()){ LOG.error("Got service exception: "+response.getException()); throw new IOException("Service exception"+response.getException()); }else{ this.entityBucket.clear(); } }
public void flush() throws IOException, EagleServiceClientException { if(this.entityBucket.size() == 0 && LOG.isDebugEnabled()){ LOG.debug("No entities to flush"); return; } LOG.info("Writing "+this.entityBucket.size()+" entities"); GenericServiceAPIResponseEntity<String> response = this.client.create(this.entityBucket); if(!response.isSuccess()){ LOG.error("Got service exception: "+response.getException()); throw new IOException("Service exception"+response.getException()); }else{ this.entityBucket.clear(); } }
public void emitMetric(GenericMetricEntity metricEntity) { entityBucket.add(metricEntity); if (entityBucket.size() < batchSize) { return; } try { GenericServiceAPIResponseEntity response = client.create(entityBucket); if (response.isSuccess()) { LOG.info("persist {} entities with the earliest time={}", entityBucket.size(), entityBucket.get(0).getTimestamp()); } else { LOG.error("Service side error: {}", response.getException()); } } catch (Exception e) { LOG.error(e.getMessage(), e); } finally { entityBucket.clear(); } }
private void writeEntities(List<? extends TaggedLogAPIEntity> entities, List<GenericMetricEntity> metrics, String serviceName) { try { GenericServiceAPIResponseEntity response = client.create(entities); if (!response.isSuccess()) { LOG.error("Got exception from eagle service: " + response.getException()); } else { LOG.info("Successfully wrote {} entities for {}", entities.size(), serviceName); } response = client.create(metrics); if (!response.isSuccess()) { LOG.error("Got exception from eagle service: " + response.getException()); } else { LOG.info("Successfully wrote {} metrics for {}", metrics.size(), serviceName); } } catch (Exception e) { LOG.error("cannot create entities successfully", e); } entities.clear(); }
public boolean flush() { //need flush right now if (entities.size() == 0) { return true; } try (IEagleServiceClient client = new EagleServiceClientImpl( eagleServiceConfig.eagleServiceHost, eagleServiceConfig.eagleServicePort, eagleServiceConfig.username, eagleServiceConfig.password)) { client.setReadTimeout(eagleServiceConfig.readTimeoutSeconds * 1000); LOG.info("start to flush spark app entities, size {}", entities.size()); client.create(entities); LOG.info("finish flushing spark app entities, size {}", entities.size()); entities.clear(); } catch (Exception e) { LOG.warn("exception found when flush entities, {}", e); e.printStackTrace(); return false; } return true; } }
@Override public void updatePolicyDetails(T entity) { IEagleServiceClient client = new EagleServiceClientImpl(connector); List<T> entityList = new ArrayList<>(); entityList.add(entity); try { client.create(entityList, servicePointName); } catch (IOException | EagleServiceClientException exception) { LOG.error("Exception in updating markdown for policy in HBase ", exception); } finally { try { if (null != client) client.close(); } catch (IOException exception) { LOG.error("Unable to close Eagle service client ", exception); } } } }
private void generateMetric(TopWindowResult.Op op, int windowLen, long timestamp) { List<GenericMetricEntity> metrics = new ArrayList<>(); GenericMetricEntity clusterMetric = buildMetricEntity(timestamp, CLUSTER_METRIC_FORMAT, null, op.getTotalCount(), windowLen); metrics.add(clusterMetric); collector.emit(new Values("", buildStreamEvent(clusterMetric))); for (TopWindowResult.User user : op.getTopUsers()) { GenericMetricEntity metric = buildMetricEntity(timestamp, USER_METRIC_FORMAT, user.getUser(), user.getCount(), windowLen); metrics.add(metric); collector.emit(new Values("", buildStreamEvent(metric))); } try { client.create(metrics); LOG.info("successfully create {} metrics", metrics.size()); } catch (Exception e) { LOG.error("create {} metrics failed due to {}", metrics.size(), e.getMessage(), e); } }
private void createMetricSchemaEntity(String metricName, Map event, MetricDescriptor metricDescriptor) throws IOException, EagleServiceClientException { MetricSchemaEntity schemaEntity = new MetricSchemaEntity(); Map<String, String> schemaTags = new HashMap<>(); schemaEntity.setTags(schemaTags); schemaTags.put(MetricSchemaEntity.METRIC_SITE_TAG, metricDescriptor.getSiteIdSelector().getSiteId(event)); schemaTags.put(MetricSchemaEntity.METRIC_NAME_TAG, metricName); schemaTags.put(MetricSchemaEntity.METRIC_GROUP_TAG, metricDescriptor.getMetricGroupSelector().getMetricGroup(event)); schemaEntity.setGranularityByField(metricDescriptor.getGranularity()); schemaEntity.setDimensionFields(metricDescriptor.getDimensionFields()); schemaEntity.setMetricFields(Collections.singletonList(GENERIC_METRIC_VALUE_NAME)); schemaEntity.setModifiedTimestamp(System.currentTimeMillis()); GenericServiceAPIResponseEntity<String> response = this.client.create(Collections.singletonList(schemaEntity)); if (response.isSuccess()) { if (LOG.isDebugEnabled()) { LOG.debug("Created {}", schemaEntity); } } else { LOG.error("Failed to create {}", schemaEntity, response.getException()); throw new IOException("Service error: " + response.getException()); } } }
/** * 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(); } }