Search in sources :

Example 1 with GridLoggerProxy

use of org.apache.ignite.internal.GridLoggerProxy in project ignite by apache.

the class HadoopIgfsIpcIo method start.

/**
     * Starts the IO.
     *
     * @throws IgniteCheckedException If failed to connect the endpoint.
     */
private void start() throws IgniteCheckedException {
    boolean success = false;
    try {
        endpoint = IpcEndpointFactory.connectEndpoint(endpointAddr, new GridLoggerProxy(new HadoopIgfsJclLogger(log), null, null, ""));
        out = new IgfsDataOutputStream(new BufferedOutputStream(endpoint.outputStream()));
        reader = new ReaderThread();
        // Required for Hadoop 2.x
        reader.setDaemon(true);
        reader.start();
        success = true;
    } catch (IgniteCheckedException e) {
        IpcOutOfSystemResourcesException resEx = e.getCause(IpcOutOfSystemResourcesException.class);
        if (resEx != null)
            throw new IgniteCheckedException(IpcSharedMemoryServerEndpoint.OUT_OF_RESOURCES_MSG, resEx);
        throw e;
    } finally {
        if (!success)
            stop();
    }
}
Also used : GridLoggerProxy(org.apache.ignite.internal.GridLoggerProxy) IgniteCheckedException(org.apache.ignite.IgniteCheckedException) IpcOutOfSystemResourcesException(org.apache.ignite.internal.util.ipc.shmem.IpcOutOfSystemResourcesException) IgfsDataOutputStream(org.apache.ignite.internal.igfs.common.IgfsDataOutputStream) BufferedOutputStream(java.io.BufferedOutputStream)

Example 2 with GridLoggerProxy

use of org.apache.ignite.internal.GridLoggerProxy in project ignite by apache.

the class GridLoggerInjectionSelfTest method testClosureMethod.

/**
     * Test that closure gets right log category injected on all nodes using method injection.
     *
     * @throws Exception If failed.
     */
public void testClosureMethod() throws Exception {
    Ignite ignite = grid(0);
    ignite.compute().call(new IgniteCallable<Object>() {

        @LoggerResource(categoryClass = GridLoggerInjectionSelfTest.class)
        private void log(IgniteLogger log) {
            if (log instanceof GridLoggerProxy) {
                Object category = U.field(log, "ctgr");
                assertTrue("Logger created for the wrong category.", category.toString().contains(GridLoggerInjectionSelfTest.class.getName()));
            } else
                fail("This test should be run with proxy logger.");
        }

        @Override
        public Object call() throws Exception {
            return null;
        }
    });
}
Also used : LoggerResource(org.apache.ignite.resources.LoggerResource) GridLoggerProxy(org.apache.ignite.internal.GridLoggerProxy) Ignite(org.apache.ignite.Ignite) IgniteLogger(org.apache.ignite.IgniteLogger) IOException(java.io.IOException)

Example 3 with GridLoggerProxy

use of org.apache.ignite.internal.GridLoggerProxy in project ignite by apache.

the class GridLoggerInjectionSelfTest method testStringCategory.

/**
     * Test that closure gets right log category injected through {@link org.apache.ignite.resources.LoggerResource#categoryName()}.
     *
     * @throws Exception If failed.
     */
public void testStringCategory() throws Exception {
    Ignite ignite = grid(0);
    ignite.compute().call(new IgniteCallable<Object>() {

        @LoggerResource(categoryName = "GridLoggerInjectionSelfTest")
        private void log(IgniteLogger log) {
            if (log instanceof GridLoggerProxy) {
                Object category = U.field(log, "ctgr");
                assertTrue("Logger created for the wrong category.", "GridLoggerInjectionSelfTest".equals(category.toString()));
            } else
                fail("This test should be run with proxy logger.");
        }

        @Override
        public Object call() throws Exception {
            return null;
        }
    });
}
Also used : LoggerResource(org.apache.ignite.resources.LoggerResource) GridLoggerProxy(org.apache.ignite.internal.GridLoggerProxy) Ignite(org.apache.ignite.Ignite) IgniteLogger(org.apache.ignite.IgniteLogger) IOException(java.io.IOException)

Example 4 with GridLoggerProxy

use of org.apache.ignite.internal.GridLoggerProxy in project ignite by apache.

the class GridLoggerInjectionSelfTest method testClosureField.

/**
     * Test that closure gets right log category injected on all nodes using field injection.
     *
     * @throws Exception If failed.
     */
public void testClosureField() throws Exception {
    Ignite ignite = grid(0);
    ignite.compute().call(new IgniteCallable<Object>() {

        @LoggerResource(categoryClass = GridLoggerInjectionSelfTest.class)
        private IgniteLogger log;

        @Override
        public Object call() throws Exception {
            if (log instanceof GridLoggerProxy) {
                Object category = U.field(log, "ctgr");
                assertTrue("Logger created for the wrong category.", category.toString().contains(GridLoggerInjectionSelfTest.class.getName()));
            } else
                fail("This test should be run with proxy logger.");
            return null;
        }
    });
}
Also used : LoggerResource(org.apache.ignite.resources.LoggerResource) GridLoggerProxy(org.apache.ignite.internal.GridLoggerProxy) Ignite(org.apache.ignite.Ignite) IgniteLogger(org.apache.ignite.IgniteLogger) IOException(java.io.IOException)

Aggregations

GridLoggerProxy (org.apache.ignite.internal.GridLoggerProxy)4 IOException (java.io.IOException)3 Ignite (org.apache.ignite.Ignite)3 IgniteLogger (org.apache.ignite.IgniteLogger)3 LoggerResource (org.apache.ignite.resources.LoggerResource)3 BufferedOutputStream (java.io.BufferedOutputStream)1 IgniteCheckedException (org.apache.ignite.IgniteCheckedException)1 IgfsDataOutputStream (org.apache.ignite.internal.igfs.common.IgfsDataOutputStream)1 IpcOutOfSystemResourcesException (org.apache.ignite.internal.util.ipc.shmem.IpcOutOfSystemResourcesException)1