/** * Stops logging clients. This is a blocking call. */ public void stop() { service.shutdown(); if (!service.isTerminated()) { service.shutdownNow(); try { service.awaitTermination(1000, TimeUnit.SECONDS); } catch (InterruptedException e) { LOGGER.error("exception awaiting termination", e); } } LOGGER.info("Logging clients stopped"); }
@Override @SuppressWarnings("unchecked") public <T extends Provider> T provider(Class<T> clazz) { Provider provider = m_providers.get(clazz); if (provider != null) { return (T) provider; } else { logger.error("No provider [{}] found in DefaultProviderManager, please make sure it is registered in DefaultProviderManager ", clazz.getName()); return (T) NullProviderManager.provider; } }
public static void setClipboardString(String text) { try { Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard(); Transferable transferable = new StringSelection(text); clipboard.setContents(transferable, null); LOG.debug("String '{}' copied to clipboard", text); } catch (Exception e) { LOG.error("Failed copy string '{}' to clipboard", text, e); } } }
private void notifyStart(File instanceDir, String destination, File[] instanceConfigs) { try { defaultAction.start(destination); actions.put(destination, defaultAction); // 启动成功后记录配置文件信息 InstanceConfigFiles lastFile = lastFiles.get(destination); List<FileInfo> newFileInfo = new ArrayList<FileInfo>(); for (File instanceConfig : instanceConfigs) { newFileInfo.add(new FileInfo(instanceConfig.getName(), instanceConfig.lastModified())); } lastFile.setInstanceFiles(newFileInfo); logger.info("auto notify start {} successful.", destination); } catch (Throwable e) { logger.error(String.format("scan add found[%s] but start failed", destination), e); } }
private void handleEnvDown(Env env) { int failedTimes = healthCheckFailedCounter.get(env); healthCheckFailedCounter.put(env, ++failedTimes); if (!envStatusMark.get(env)) { logger.error("Env is down. env: {}, failed times: {}, meta server address: {}", env, failedTimes, MetaDomainConsts.getDomain(env)); } else { if (failedTimes >= ENV_DOWN_THRESHOLD) { envStatusMark.put(env, false); logger.error("Env is down because health check failed for {} times, " + "which equals to down threshold. env: {}, meta server address: {}", ENV_DOWN_THRESHOLD, env, MetaDomainConsts.getDomain(env)); } else { logger.error( "Env health check failed for {} times which less than down threshold. down threshold:{}, env: {}, meta server address: {}", failedTimes, ENV_DOWN_THRESHOLD, env, MetaDomainConsts.getDomain(env)); } } }
@Override public void onEvent(RawMessageEvent event, long sequence, boolean endOfBatch) throws Exception { batch.add(event); log.debug("End of batch, journalling {} messages", batch.size()); writeToJournal(converter, entries); } catch (Exception e) { log.error("Unable to write to journal - retrying", e);
static public List<String> checkMd5() { List<String> diffList = new ArrayList<String>(); long startTime = System.currentTimeMillis(); for (Entry<String/* groupKey */, CacheItem> entry : CACHE.entrySet()) { String groupKey = entry.getKey(); String[] dg = GroupKey.parseKey(groupKey); String dataId = dg[0]; String group = dg[1]; String tenant = dg[2]; try { String loacalMd5 = DiskUtil.getLocalConfigMd5(dataId, group, tenant); if (!entry.getValue().md5.equals(loacalMd5)) { defaultLog.warn("[md5-different] dataId:{},group:{}", dataId, group); diffList.add(groupKey); } } catch (IOException e) { defaultLog.error("getLocalConfigMd5 fail,dataId:{},group:{}", dataId, group); } } long endTime = System.currentTimeMillis(); defaultLog.warn("checkMd5 cost:{}; diffCount:{}", endTime - startTime, diffList.size()); return diffList; }
private List<AwsEndpoint> getClusterEndpointsFromConfig() { String[] availZones = clientConfig.getAvailabilityZones(clientConfig.getRegion()); String myZone = InstanceInfo.getZone(availZones, myInstanceInfo); Map<String, List<String>> serviceUrls = EndpointUtils .getServiceUrlsMapFromConfig(clientConfig, myZone, clientConfig.shouldPreferSameZoneEureka()); List<AwsEndpoint> endpoints = new ArrayList<>(); for (String zone : serviceUrls.keySet()) { for (String url : serviceUrls.get(zone)) { try { endpoints.add(new AwsEndpoint(url, getRegion(), zone)); } catch (Exception ignore) { logger.warn("Invalid eureka server URI: {}; removing from the server pool", url); } } } logger.debug("Config resolved to {}", endpoints); if (endpoints.isEmpty()) { logger.error("Cannot resolve to any endpoints from provided configuration: {}", serviceUrls); } return endpoints; }
private URL[] enumerateJar(URL urlOfJar) { LOGGER.debug("Enumerating jar: {}", urlOfJar); List<URL> urls = new ArrayList<>(); urls.add(urlOfJar); try { JarInputStream jarStream = new JarInputStream(urlOfJar.openStream()); JarEntry entry; while ((entry = jarStream.getNextJarEntry()) != null) { if (!entry.isDirectory() && entry.getName().endsWith(".jar")) { urls.add(expandJarAndReturnURL(jarStream, entry)); } } } catch (IOException e) { LOGGER.error("Failed to enumerate jar {}", urlOfJar, e); } return urls.toArray(new URL[0]); }
@Override public void log (int level, String category, String message, Throwable ex) { final String logString = "[KRYO " + category + "] " + message; switch (level) { case Log.LEVEL_ERROR: log.error(logString, ex); break; case Log.LEVEL_WARN: log.warn(logString, ex); break; case Log.LEVEL_INFO: log.info(logString, ex); break; case Log.LEVEL_DEBUG: log.debug(logString, ex); break; case Log.LEVEL_TRACE: log.trace(logString, ex); break; } } }
protected void logException() { if (exception instanceof JobNotFoundException || exception instanceof ActivitiTaskAlreadyClaimedException) { // reduce log level, because this may have been caused because of job deletion due to cancelActiviti="true" log.info("Error while closing command context", exception); } else if (exception instanceof ActivitiOptimisticLockingException) { // reduce log level, as normally we're not interested in logging this exception log.debug("Optimistic locking exception : " + exception); } else { log.error("Error while closing command context", exception); } }
public void close() { closed = true; if (serverSocket != null) { try { serverSocket.close(); } catch (IOException e) { logger.error("Failed to close serverSocket", e); } finally { serverSocket = null; } } logger.info("closing this server"); synchronized (socketNodeList) { for (SocketNode sn : socketNodeList) { sn.close(); } } if (socketNodeList.size() != 0) { logger.warn("Was expecting a 0-sized socketNodeList after server shutdown"); } }
private static List<String> getZipFileList(File file) { List<String> filesList = new ArrayList<>(); try (ZipFile zipFile = new ZipFile(file)) { Enumeration<? extends ZipEntry> entries = zipFile.entries(); while (entries.hasMoreElements()) { ZipEntry entry = entries.nextElement(); filesList.add(entry.getName()); } } catch (Exception e) { LOG.error("Error read zip file '{}'", file.getAbsolutePath(), e); } return filesList; }
@Override public void onCheckMessage(long msgId, ChannelHandlerContext ctx, ServerMessageSender sender) { try { sender.sendResponse(msgId, ctx.channel(), HeartbeatMessage.PONG); } catch (Throwable throwable) { LOGGER.error("", "send response error", throwable); } if (LOGGER.isDebugEnabled()) { LOGGER.debug("received PING from " + ctx.channel().remoteAddress()); } }
futures.add(groupInnerExecutorService.submit(() -> { try { batchSync(dmls, adapter); if (logger.isDebugEnabled()) { logger.debug("{} elapsed time: {}", adapter.getClass().getName(), (System.currentTimeMillis() - begin)); return true; } catch (Exception e) { logger.error(e.getMessage(), e); return false;
public void printReport() { if (getErrorCount() > 0) { LOG.error("{} errors occurred in following nodes:", getErrorCount()); List<String> errors = new ArrayList<>(errorNodes.size()); for (IAttributeNode node : errorNodes) { String nodeName = node.getClass().getSimpleName().replace("Node", ""); errors.add(nodeName + ": " + node); } Collections.sort(errors); for (String err : errors) { LOG.error(" {}", err); } } if (getWarnsCount() > 0) { LOG.warn("{} warnings in {} nodes", getWarnsCount(), warnNodes.size()); } } }
private void notifyStop(String destination) { InstanceAction action = actions.remove(destination); try { action.stop(destination); lastFiles.remove(destination); logger.info("auto notify stop {} successful.", destination); } catch (Throwable e) { logger.error(String.format("scan delete found[%s] but stop failed", destination), e); actions.put(destination, action);// 再重新加回去,下一次scan时再执行删除 } }
private void loadConnector(OuterAdapterConfig config, List<OuterAdapter> canalOutConnectors) { try { OuterAdapter adapter; adapter = loader.getExtension(config.getName(), StringUtils.trimToEmpty(config.getKey())); ClassLoader cl = Thread.currentThread().getContextClassLoader(); // 替换ClassLoader Thread.currentThread().setContextClassLoader(adapter.getClass().getClassLoader()); adapter.init(config); Thread.currentThread().setContextClassLoader(cl); canalOutConnectors.add(adapter); logger.info("Load canal adapter: {} succeed", config.getName()); } catch (Exception e) { logger.error("Load canal adapter: {} failed", config.getName(), e); } }
private void notifyReload(String destination) { InstanceAction action = actions.get(destination); if (action != null) { try { action.reload(destination); logger.info("auto notify reload {} successful.", destination); } catch (Throwable e) { logger.error(String.format("scan reload found[%s] but reload failed", destination), e); } } }