/** * Creates a new Script object. * * @param script * the script * @param timeout * * @return the script */ public static Script createScript(String script, String id, WrappedProcess process, String[] args, InternalLogger log, int timeout, String encoding, boolean reload, int debug, int maxConcInvocations) { if (script == null || "".equals(script)) return null; if (log != null && debug > 1) log.info("create script: " + script); if (script.endsWith(".bat") || script.endsWith(".sh")) return new ShellScript(script, id, process, args, timeout, maxConcInvocations); if (script.endsWith(".gv") || script.endsWith(".groovy")) try { return new GroovyScript(script, id, process, args, timeout, log, encoding, reload, maxConcInvocations); } catch (Throwable e) { if (log != null) log.info("Error in createScript " + script, e); } return null; }
/** * Instantiates a new groovy script. * * @param script * the script * @param timeout * @throws IOException * @throws CompilationFailedException * @throws IllegalAccessException * @throws InstantiationException * @throws ClassNotFoundException */ public GroovyScript(final String script, final String id, final WrappedProcess process, final String[] args, final int timeout, final InternalLogger logger, String encoding, boolean reload, int maxConcInvocations) throws CompilationFailedException, IOException, InstantiationException, IllegalAccessException, ClassNotFoundException { super(script, id, process, args, timeout, maxConcInvocations); _reload = reload; _encoding = encoding; // let's call some method on an instance _script = getScriptInstance(script, encoding); binding = (Binding) _script.invokeMethod("getBinding", null); binding.setVariable("args", args); binding.setVariable("callCount", 0); binding.setVariable("context", context); if (process != null && logger == null) _logger = process.getInternalWrapperLogger(); else _logger = logger; binding.setVariable("logger", _logger); }
public AHessianJmxClient(String discoveryName, int port, boolean debug, InternalLogger logger) throws Exception { _discoveryName = discoveryName; _port = port; _debug = debug; _logger = logger; Map options = new HashMap(); options.put("sync", true); options.put("timeout", (long) 5000); final ChannelPipelineFactoryBuilder<MBeanServerConnection> builder = new ChannelPipelineFactoryBuilder<MBeanServerConnection>() .serviceThreads(10).reconnect(10) .rpcServiceInterface(MBeanServerConnection.class) .serviceOptions(options); builder.debug(); builder.serializerFactory(new JmxSerializerFactory()); final Set<String> channelOptions = new HashSet(); channelOptions.add("SO_REUSE"); channelOptions.add("TCP_NODELAY"); client = new DefaultClient<MBeanServerConnection>( OioSocketChannel.class, builder, channelOptions); }
public static void logMethodCall(Object object, String methodName, Object[] arguments) { String className = getClassName(object); String logname = "methodCalls." + className + "." + methodName; InternalLogger objLog = InternalLoggerFactory.getInstance(logname); if (!objLog.isTraceEnabled()) return; StringBuilder msg = new StringBuilder(methodName); msg.append("("); if (arguments != null) { for (int i = 0; i < arguments.length;) { msg.append(normalizedValue(arguments[i])); if (++i < arguments.length) { msg.append(","); } } } msg.append(")"); objLog.log(InternalLogLevel.TRACE, className, msg.toString(), "called from MetaClass.invokeMethod"); }
/** * Init timeouts and the connection registry and start the netty IO server synchronously */ @Override public void init(Container container) { super.init(container); try { // Configure netty InternalLoggerFactory.setDefaultFactory(new Slf4JLoggerFactory() { @Override public InternalLogger newInstance(String name) { return new NettyInternalLogger(name); } }); ResourceLeakDetector.setLevel(CoreConstants.NettyConstants.RESOURCE_LEAK_DETECTION); // Start server startServer(); } catch (InterruptedException e) { throw new StartupException("Could not start netty server", e); } }
/** * Configure netty and initialize related Components. * Afterwards call {@link #initClient()} method to start the netty IO client asynchronously. */ @Override public void init(Container container) { super.init(container); // Configure netty InternalLoggerFactory.setDefaultFactory(new Slf4JLoggerFactory() { @Override public InternalLogger newInstance(String name) { return new NettyInternalLogger(name); } }); ResourceLeakDetector.setLevel(CoreConstants.NettyConstants.RESOURCE_LEAK_DETECTION); // And try to connect isActive = true; initClient(); // register BroadcastListener IntentFilter filter = new IntentFilter(); filter.addAction(WifiManager.SUPPLICANT_CONNECTION_CHANGE_ACTION); filter.addAction(WifiManager.NETWORK_STATE_CHANGED_ACTION); filter.addAction(WifiManager.WIFI_STATE_CHANGED_ACTION); filter.addAction(ConnectivityManager.CONNECTIVITY_ACTION); requireComponent(ContainerService.KEY_CONTEXT).registerReceiver(broadcastReceiver, filter); }
public void retain() { if (counter.incrementAndGet() == 1) { if (instanceCounter.getAndIncrement() > 0) { InternalLogger instance = InternalLoggerFactory.getInstance(getClass()); instance.info("Initialized PauseDetectorWrapper more than once."); } pauseDetector = new SimplePauseDetector(TimeUnit.MILLISECONDS.toNanos(10), TimeUnit.MILLISECONDS.toNanos(10), 3); Runtime.getRuntime().addShutdownHook(new Thread("ShutdownHook for SimplePauseDetector") { @Override public void run() { if (pauseDetector != null) { pauseDetector.shutdown(); } } }); } }
public static Script createScript(String script, String id, WrappedProcess process, List args, InternalLogger log, int timeout, String encoding, boolean reload, int debug, int maxConcInvocations) { String[] argsArr = new String[0]; if (args != null && args.size() > 0) { argsArr = new String[args.size()]; for (int i = 0; i < argsArr.length; i++) argsArr[i] = args.get(i).toString(); } return createScript(script, id, process, argsArr, log, timeout, encoding, reload, debug, maxConcInvocations); }
public static void setAhessianLogger(final Logger log) { InternalLoggerFactory.setDefaultFactory(new InternalLoggerFactory() { @Override public InternalLogger newInstance(String name) { return (InternalLogger) new JdkLogger(log, "ahessian-jmx"); } }); }
public Condition(YajswConfigurationImpl config, WrappedProcess wrappedProcess, InternalLogger log) { _config = config; _wp = wrappedProcess; _log = log; }
public static LeakCounter installLeakTrap(){ try { Field loggerField = ResourceLeakDetector.class.getDeclaredField("logger"); loggerField.setAccessible(true); Field modifiersField = Field.class.getDeclaredField("modifiers"); modifiersField.setAccessible(true); modifiersField.setInt(loggerField, loggerField.getModifiers() & ~Modifier.FINAL); InternalLogger leakLogger = (InternalLogger)loggerField.get(null); if (leakLogger instanceof LeakCounter) { logger.debug("leak counter already installed."); return (LeakCounter) leakLogger; }else if (leakLogger != null){ logger.debug("monkeypatching leak counter into Netty leak detection."); LeakTrap trap = new LeakTrap(leakLogger); loggerField.set(null, trap); return trap; } else { throw new NullPointerException("Netty ResourceLeakDetector had null logger reference?"); } } catch (Throwable t){ t.printStackTrace(); logger.warn("Couldn't monkeypatch leak counter into netty leak detection, returning noop counter to tests."); return new NoopLeakTrap(); } }
@Override public InternalLogger newInstance(final String name) { return new Netty4InternalESLogger(name); }
public static InternalLogger getLogger(Class<?> c) { return InternalLoggerFactory.getInstance(c); }
public void setLogger(InternalLogger logger) { this.logger = logger; }
public void setLogger(InternalLogger logger, int debug) { _logger = logger; _debug = debug; }
public AHessianJmxServer(MBeanServer mbeanServer, String ipFilter, String serviceDiscoveryName, int port, InternalLogger logger, int debug, InetAddress address) throws Exception { // InternalLoggerFactory.setDefaultFactory(new SimpleLoggerFactory()); ChannelPipelineFactoryBuilder builder = new ChannelPipelineFactoryBuilder() .serializerFactory(new JmxSerializerFactory()) .rpcServiceInterface(MBeanServerConnection.class) .rpcServerService(mbeanServer).serviceThreads(10) .ipFilter(ipFilter); if (debug > 2) builder.debug(); Set<String> channelOptions = new HashSet(); // channelOptions.add("SO_REUSE"); channelOptions.add("TCP_NODELAY"); int serverPort = port; DefaultServer server = new DefaultServer(OioServerSocketChannel.class, builder, channelOptions, serverPort, address); server.start(); Channel channel = server.getChannel(); Executor executor = Executors.newCachedThreadPool(); if (serverPort == 0) serverPort = ((InetSocketAddress) channel.localAddress()).getPort(); if (debug > 2 && logger != null) logger.info("ahessian jmx service bound to port " + serverPort); DiscoveryServer discovery = new DiscoveryServer(); discovery.setDebug(debug > 2); discovery.setLogger(logger); // allow discovery only from localhost. other computers will be ignored discovery.setIpSet(new IpFilterRuleList("+n:localhost, -n:*")); discovery.setName(serviceDiscoveryName); discovery.setPort(serverPort); discovery.init(); }
public InternalLogger getInternalWrapperLogger() { if (_internalLoggerFactory == null) _internalLoggerFactory = new JdkLogger2Factory(getWrapperLogger()); return _internalLoggerFactory.newInstance(""); }
public CommonsLoggingAdapter(InternalLogger log) { _log = log; }
public static void setLogger(InternalLogger logger) { fsManager.setLogger(new CommonsLoggingAdapter(logger)); }
public ConfigurationLoggingAdapter(final InternalLogger log) { _log = log; }
private InternalLogger getILog() { return _log; }
@Override public InternalLogger newInstance(String name) { return new DubboLogger(LoggerFactory.getLogger(name)); }
@Override protected InternalLogger newInstance(final String name) { return new NettyLog4j2Logger(logger); }
@Override protected InternalLogger newInstance(String name) { return new LtsLogger(name); }
@Override protected InternalLogger newInstance(final String name) { return NettyLogger.instance; }
public LeakTrap(InternalLogger delegate) { this.delegate = delegate; }
@Override protected InternalLogger newInstance(String arg0) { return LoggerFactory.instance; }
@Override protected InternalLogger newInstance(final String name) { return new Log4j2Logger(LogManager.getLogger(name)); }
void setLogger(InternalLogger logger, int level);
public InternalLogger getInternalWrapperLogger();