@Override public void rejectedExecution(Runnable r, ThreadPoolExecutor executor) { LOG.error(String.format("A job was rejected. [%s]", r)); } }
/** * Logs a message at error level. * * @param logger * @param msg */ public void error(EELFLogger logger, String msg) { MDC.put(LoggerProperties.MDC_CLASS_NAME, className); logger.error(msg); MDC.remove(LoggerProperties.MDC_CLASS_NAME); }
private void clearRequestLogProperties() { try { MDC.remove(MDC_KEY_REQUEST_ID); MDC.remove(MDC_SERVICE_INSTANCE_ID); MDC.remove(MDC_SERVICE_NAME); MDC.remove(LoggingConstants.MDCKeys.PARTNER_NAME); } catch (Exception e) { logger.error(e.getMessage(),e); } }
private static String[] getKeys(String keyString) { log.error("Received Key String as :" + keyString); String key = keyString .replace("[", "") .replace("]", "") .replace("\"", ""); if (key.contains(",")) { return key.split(","); } else { return new String[]{key}; } }
private void logArtifact(PropertyDefinition artifact) { ObjectMapper mapper = new ObjectMapper(new YAMLFactory()); String stringArtifact = null; try { stringArtifact = mapper.writeValueAsString(artifact); Log.info("Received PropertyDefinition:\n" + stringArtifact); } catch (JsonProcessingException e) { Log.error("Exception while logging artifact:", e); } } }
/** * Cancel the scheduled {@link BaseActionRunnable} through AsyncTaskHelper */ void cancelAsyncTask() { if (scheduledRunnable == null) { logger.error(String.format( "Skipped cancel schedule async task for rpc(%s) due to scheduledRunnable is null", rpc.name())); return; } scheduledRunnable.cancel(true); }
public ProviderOperations(String url, String username, String password){ setAuthentication(username, password); try { this.url = new URL(url); } catch (MalformedURLException e) { LOG.error("An error occurred while building url", e); } }
private String extractRequestIdWithSubId(JsonNode event) { String requestId = ""; try { requestId = Converter.extractRequestIdWithSubId(event); } catch (Exception e) { LOG.error("failed to parse request-id and sub-request-id. Json not in expected format", e); } return requestId; }
public static String getKafkaproperty(){ InputStream input = new Utils().getClass().getResourceAsStream("/kafka.properties"); Properties props = new Properties(); try { props.load(input); } catch (IOException e) { log.error("failed to read kafka.properties"); } return props.getProperty("key"); }
@Override public ResponseStatus getResponseStatus(JsonNode responseBody)throws APPCException{ try { JsonNode status = responseBody.get("output").get("status"); return new ResponseStatus(status.get("code").asInt(), status.get("message").asText()); } catch (Exception e) { LOG.error("Unknown error processing failed response from provider. Json not in expected format", e); throw new APPCException("APPC has an unknown RPC error"); } }
@Override public void generateArtifact(String artifact, OutputStream stream) throws ArtifactProcessorException { ObjectMapper mapper = new ObjectMapper(new YAMLFactory()); try { PropertyDefinition pd = mapper.readValue(artifact, PropertyDefinition.class); generateArtifact(pd, stream); } catch (IOException e) { Log.error("Error parsing property definition content = " + artifact, e); throw new ArtifactProcessorException(e); } }
public void run() { try { publisher.publish(metricRegistry, metrics); reset(); } catch (RuntimeException ex) { logger.error("RuntimeException thrown from {}#report. Exception was suppressed.", publisher.getClass().getSimpleName(), ex); } } }
@Override public void storeYangModule(String yang, BundleInfo bundleInfo) throws MDSALStoreException { BundleContext bundleContext = FrameworkUtil.getBundle(this.getClass()).getBundleContext(); byte[] byteArray = createBundleJar(yang, Constants.BLUEPRINT, bundleInfo); try (ByteArrayInputStream inputStream = new ByteArrayInputStream(byteArray)) { Bundle bundle = bundleContext.installBundle(bundleInfo.getLocation(), inputStream); bundle.start(); } catch (Exception e) { logger.error(String.format("Error storing yang module: %s. Error message: %s.", yang, e.getMessage())); throw new MDSALStoreException("Error storing yang module: " + yang + " " + e.getMessage(), e); } }
private static void logError(String errorCode, String errorDescription, String targetEntity, String targetServiceName, String additionalMessage, String className) { populateErrorLogContext(errorCode, errorDescription, targetEntity, targetServiceName, className); errorLogger.error(additionalMessage == null ? "" : additionalMessage); cleanErrorLogContext(); }
/** * Schedule async task through AsyncTaskHelper. */ protected void scheduleAsyncTask() { if (runnable == null) { logger.error(String.format( "Skipped schedule async task for rpc(%s) due to runnable is null", rpc.name())); return; } scheduledRunnable = asyncTaskHelper.scheduleBaseRunnable( runnable, runnable::abortRunnable, getInitialDelayMillis(), getDelayMillis()); }
@SuppressWarnings("deprecation") @Override public void configure(String configuration, String deviceMountPointName, String moduleName, String nodeName) throws APPCException { logger.info("Configuring device "+deviceMountPointName+" with configuration "+configuration); int httpCode = httpClient.putMethod(Constants.PROTOCOL,Constants.CONTROLLER_IP,Constants.CONTROLLER_PORT,getModuleConfigurePath(deviceMountPointName, moduleName, nodeName),configuration,"application/json"); if (httpCode != HttpStatus.SC_OK) { logger.error("Configuration request failed. throwing Exception !"); throw new APPCException("Error configuring node :"+nodeName + ", of Module :" + moduleName + ", in device :" + deviceMountPointName); } }
@Override public void connect(String deviceMountPointName, String payload) throws APPCException{ logger.info("Connecting device "+deviceMountPointName); int httpCode = httpClient.postMethod(Constants.PROTOCOL,Constants.CONTROLLER_IP,Constants.CONTROLLER_PORT,getConnectPath(),payload,"application/json"); if(httpCode != HttpStatus.SC_NO_CONTENT){ logger.error("Connect request failed with code "+httpCode+". throwing Exception !"); throw new APPCException("Error connecting device :" + deviceMountPointName); } }
@Override public void disconnect(String deviceMountPointName) throws APPCException { logger.info("Disconnecting "+deviceMountPointName); int httpCode = httpClient.deleteMethod(Constants.PROTOCOL,Constants.CONTROLLER_IP,Constants.CONTROLLER_PORT,getDisconnectPath(deviceMountPointName),"application/json"); if(httpCode != HttpStatus.SC_OK){ logger.error("Disconnection of device "+deviceMountPointName+" failed!"); throw new APPCException("Disconnection of device "+deviceMountPointName+" failed!"); } }
@Override public String getConfiguration(String deviceMountPointName, String moduleName, String nodeName) throws APPCException{ logger.info("Getting configuration of device "+deviceMountPointName); String result = httpClient.getMethod(Constants.PROTOCOL,Constants.CONTROLLER_IP,Constants.CONTROLLER_PORT,getModuleConfigurePath(deviceMountPointName, moduleName, nodeName),"application/json"); if (result == null) { logger.error("Configuration request failed. throwing Exception !"); throw new APPCException("Error getting configuration of node :"+nodeName + ", of Module :" + moduleName + ", in device :" + deviceMountPointName); } return result; }
public static synchronized void assertTemplateKeyValueNotNull(Map<String, Object> componentContext, ResourceAssignment resourceAssignment) throws ConfigModelException { if (resourceAssignment != null && resourceAssignment.getProperty() != null && BooleanUtils.isTrue(resourceAssignment.getProperty().getRequired()) && getTemplateKeyValue(componentContext, resourceAssignment) == null) { logger.error("failed to populate mandatory resource mapping ({})", resourceAssignment); throw new ConfigModelException( String.format("failed to populate mandatory resource mapping (%s)", resourceAssignment)); } }