Search in sources :

Example 1 with JavaLogger

use of org.apache.ignite.logger.java.JavaLogger in project ignite by apache.

the class IgfsSharedMemoryTestClient method main.

/**
 * @param args Args.
 */
@SuppressWarnings({ "BusyWait", "InfiniteLoopStatement" })
public static void main(String[] args) {
    X.println("Starting client ...");
    // Tell our process PID to the wrapper.
    X.println(GridJavaProcess.PID_MSG_PREFIX + U.jvmPid());
    OutputStream os = null;
    try {
        IpcSharedMemoryClientEndpoint client = (IpcSharedMemoryClientEndpoint) IpcEndpointFactory.connectEndpoint("shmem:" + IpcSharedMemoryServerEndpoint.DFLT_IPC_PORT, new JavaLogger());
        os = client.outputStream();
        // Tell our shmem ids.
        X.println(SHMEM_IDS_MSG_PREFIX + client.inSpace().sharedMemoryId() + "," + client.outSpace().sharedMemoryId());
        for (; ; ) {
            X.println("Write: 123");
            os.write(123);
            Thread.sleep(IpcSharedMemoryCrashDetectionSelfTest.RW_SLEEP_TIMEOUT);
        }
    } catch (Exception e) {
        e.printStackTrace();
    } finally {
        U.closeQuiet(os);
    }
}
Also used : OutputStream(java.io.OutputStream) JavaLogger(org.apache.ignite.logger.java.JavaLogger)

Example 2 with JavaLogger

use of org.apache.ignite.logger.java.JavaLogger in project ignite by apache.

the class BPlusTreeBenchmark method createPageMemory.

/**
 * @return Page memory.
 */
private PageMemory createPageMemory() {
    DataRegionConfiguration dataRegionConfiguration = new DataRegionConfiguration().setMaxSize(1024 * MB);
    DataRegionMetricsImpl dataRegionMetrics = mock(DataRegionMetricsImpl.class);
    PageMetrics pageMetrics = mock(PageMetrics.class);
    LongAdderMetric noOpMetric = new LongAdderMetric("foobar", null);
    when(dataRegionMetrics.cacheGrpPageMetrics(anyInt())).thenReturn(pageMetrics);
    when(pageMetrics.totalPages()).thenReturn(noOpMetric);
    when(pageMetrics.indexPages()).thenReturn(noOpMetric);
    PageMemory pageMem = new PageMemoryNoStoreImpl(new JavaLogger(), new UnsafeMemoryProvider(new JavaLogger()), null, PAGE_SIZE, dataRegionConfiguration, dataRegionMetrics, false);
    pageMem.start();
    return pageMem;
}
Also used : DataRegionConfiguration(org.apache.ignite.configuration.DataRegionConfiguration) PageMemoryNoStoreImpl(org.apache.ignite.internal.pagemem.impl.PageMemoryNoStoreImpl) PageMemory(org.apache.ignite.internal.pagemem.PageMemory) PageMetrics(org.apache.ignite.internal.processors.cache.persistence.pagemem.PageMetrics) LongAdderMetric(org.apache.ignite.internal.processors.metric.impl.LongAdderMetric) DataRegionMetricsImpl(org.apache.ignite.internal.processors.cache.persistence.DataRegionMetricsImpl) JavaLogger(org.apache.ignite.logger.java.JavaLogger) UnsafeMemoryProvider(org.apache.ignite.internal.mem.unsafe.UnsafeMemoryProvider)

Example 3 with JavaLogger

use of org.apache.ignite.logger.java.JavaLogger in project ignite by apache.

the class PageIdDistributionTest method testRealHistory.

/**
 * If needed run this test manually to get data to plot histogram for per-element distance from ideal.
 * You can use Octave to plot the histogram:
 * <pre>
 *     all = csvread("histo.txt");
 *     hist(all, 200)
 * </pre>
 *
 * @throws Exception If failed.
 */
@Test
public void testRealHistory() throws Exception {
    int capacity = CACHE_IDS.length * PARTS * PAGES;
    info("Capacity: " + capacity);
    long mem = FullPageIdTable.requiredMemory(capacity);
    info(U.readableSize(mem, true));
    UnsafeMemoryProvider prov = new UnsafeMemoryProvider(new JavaLogger());
    prov.initialize(new long[] { mem });
    DirectMemoryRegion region = prov.nextRegion();
    try {
        long seed = U.currentTimeMillis();
        info("Seed: " + seed + "L; //");
        Random rnd = new Random(seed);
        FullPageIdTable tbl = new FullPageIdTable(region.address(), region.size(), true);
        Map<T2<Integer, Integer>, Integer> allocated = new HashMap<>();
        for (int i = 0; i < capacity; i++) {
            int cacheId = CACHE_IDS[rnd.nextInt(CACHE_IDS.length)];
            int partId = rnd.nextInt(PARTS);
            T2<Integer, Integer> key = new T2<>(cacheId, partId);
            Integer pageIdx = allocated.get(key);
            pageIdx = pageIdx == null ? 1 : pageIdx + 1;
            if (pageIdx > PAGES)
                continue;
            tbl.put(cacheId, PageIdUtils.pageId(partId, (byte) 0, pageIdx), 1, 0);
            allocated.put(key, pageIdx);
            if (i > 0 && i % 100_000 == 0)
                info("Done: " + i);
        }
        int[] scans = new int[capacity];
        int cur = 0;
        for (T2<Integer, Integer> key : allocated.keySet()) {
            Integer alloc = allocated.get(key);
            if (alloc != null) {
                for (int idx = 1; idx <= alloc; idx++) {
                    scans[cur] = tbl.distanceFromIdeal(key.get1(), PageIdUtils.pageId(key.get2(), (byte) 0, idx), 0);
                    assert scans[cur] != -1;
                    cur++;
                }
            }
        }
        try (FileOutputStream out = new FileOutputStream("histo.txt")) {
            PrintWriter w = new PrintWriter(new OutputStreamWriter(out));
            for (int scan : scans) {
                if (scan != 0)
                    w.println(scan);
            }
            w.flush();
        }
    } finally {
        prov.shutdown(true);
    }
}
Also used : HashMap(java.util.HashMap) DirectMemoryRegion(org.apache.ignite.internal.mem.DirectMemoryRegion) Random(java.util.Random) FileOutputStream(java.io.FileOutputStream) OutputStreamWriter(java.io.OutputStreamWriter) UnsafeMemoryProvider(org.apache.ignite.internal.mem.unsafe.UnsafeMemoryProvider) JavaLogger(org.apache.ignite.logger.java.JavaLogger) T2(org.apache.ignite.internal.util.typedef.T2) PrintWriter(java.io.PrintWriter) GridCommonAbstractTest(org.apache.ignite.testframework.junits.common.GridCommonAbstractTest) Test(org.junit.Test)

Example 4 with JavaLogger

use of org.apache.ignite.logger.java.JavaLogger in project ignite by apache.

the class PageIdDistributionTest method _testRealHistory.

/**
 * Uncomment and run this test manually to get data to plot histogram for per-element distance from ideal.
 * You can use Octave to plot the histogram:
 * <pre>
 *     all = csvread("histo.txt");
 *     hist(all, 200)
 * </pre>
 *
 * @throws Exception If failed.
 */
public void _testRealHistory() throws Exception {
    int capacity = CACHE_IDS.length * PARTS * PAGES;
    info("Capacity: " + capacity);
    long mem = FullPageIdTable.requiredMemory(capacity);
    info(U.readableSize(mem, true));
    UnsafeMemoryProvider prov = new UnsafeMemoryProvider(new JavaLogger());
    prov.initialize(new long[] { mem });
    DirectMemoryRegion region = prov.nextRegion();
    try {
        long seed = U.currentTimeMillis();
        info("Seed: " + seed + "L; //");
        Random rnd = new Random(seed);
        FullPageIdTable tbl = new FullPageIdTable(region.address(), region.size(), true);
        Map<T2<Integer, Integer>, Integer> allocated = new HashMap<>();
        for (int i = 0; i < capacity; i++) {
            int cacheId = CACHE_IDS[rnd.nextInt(CACHE_IDS.length)];
            int partId = rnd.nextInt(PARTS);
            T2<Integer, Integer> key = new T2<>(cacheId, partId);
            Integer pageIdx = allocated.get(key);
            pageIdx = pageIdx == null ? 1 : pageIdx + 1;
            if (pageIdx > PAGES)
                continue;
            tbl.put(cacheId, PageIdUtils.pageId(partId, (byte) 0, pageIdx), 1, 0);
            allocated.put(key, pageIdx);
            if (i > 0 && i % 100_000 == 0)
                info("Done: " + i);
        }
        int[] scans = new int[capacity];
        int cur = 0;
        for (T2<Integer, Integer> key : allocated.keySet()) {
            Integer alloc = allocated.get(key);
            if (alloc != null) {
                for (int idx = 1; idx <= alloc; idx++) {
                    scans[cur] = tbl.distanceFromIdeal(key.get1(), PageIdUtils.pageId(key.get2(), (byte) 0, idx), 0);
                    assert scans[cur] != -1;
                    cur++;
                }
            }
        }
        try (FileOutputStream out = new FileOutputStream("histo.txt")) {
            PrintWriter w = new PrintWriter(new OutputStreamWriter(out));
            for (int scan : scans) {
                if (scan != 0)
                    w.println(scan);
            }
            w.flush();
        }
    } finally {
        prov.shutdown();
    }
}
Also used : HashMap(java.util.HashMap) DirectMemoryRegion(org.apache.ignite.internal.mem.DirectMemoryRegion) FullPageIdTable(org.apache.ignite.internal.processors.cache.persistence.pagemem.FullPageIdTable) Random(java.util.Random) FileOutputStream(java.io.FileOutputStream) OutputStreamWriter(java.io.OutputStreamWriter) UnsafeMemoryProvider(org.apache.ignite.internal.mem.unsafe.UnsafeMemoryProvider) JavaLogger(org.apache.ignite.logger.java.JavaLogger) T2(org.apache.ignite.internal.util.typedef.T2) PrintWriter(java.io.PrintWriter)

Example 5 with JavaLogger

use of org.apache.ignite.logger.java.JavaLogger in project ignite by apache.

the class IpcSharedMemoryFakeClient method main.

/**
 * @param args Args.
 * @throws Exception If failed.
 */
public static void main(String[] args) throws Exception {
    IpcEndpointFactory.connectEndpoint("shmem:10500", new JavaLogger());
    IpcEndpointFactory.connectEndpoint("shmem:10500", new JavaLogger());
    IpcEndpointFactory.connectEndpoint("shmem:10500", new JavaLogger());
}
Also used : JavaLogger(org.apache.ignite.logger.java.JavaLogger)

Aggregations

JavaLogger (org.apache.ignite.logger.java.JavaLogger)8 FileOutputStream (java.io.FileOutputStream)2 OutputStream (java.io.OutputStream)2 OutputStreamWriter (java.io.OutputStreamWriter)2 PrintWriter (java.io.PrintWriter)2 HashMap (java.util.HashMap)2 Random (java.util.Random)2 IgniteCheckedException (org.apache.ignite.IgniteCheckedException)2 IgniteLogger (org.apache.ignite.IgniteLogger)2 UnsafeMemoryProvider (org.apache.ignite.internal.mem.unsafe.UnsafeMemoryProvider)2 File (java.io.File)1 FileNotFoundException (java.io.FileNotFoundException)1 IOException (java.io.IOException)1 UTFDataFormatException (java.io.UTFDataFormatException)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 MalformedURLException (java.net.MalformedURLException)1 SocketException (java.net.SocketException)1 SocketTimeoutException (java.net.SocketTimeoutException)1 URISyntaxException (java.net.URISyntaxException)1 URL (java.net.URL)1