当前位置: 首页>>代码示例>>Java>>正文


Java U.resolveWorkDirectory方法代码示例

本文整理汇总了Java中org.apache.ignite.internal.util.typedef.internal.U.resolveWorkDirectory方法的典型用法代码示例。如果您正苦于以下问题:Java U.resolveWorkDirectory方法的具体用法?Java U.resolveWorkDirectory怎么用?Java U.resolveWorkDirectory使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.ignite.internal.util.typedef.internal.U的用法示例。


在下文中一共展示了U.resolveWorkDirectory方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: generateAndLockNewDbStorage

import org.apache.ignite.internal.util.typedef.internal.U; //导入方法依赖的package包/类
/**
 * Creates new DB storage folder.
 *
 * @param pstStoreBasePath DB root path.
 * @param nodeIdx next node index to use in folder name.
 * @return new settings to be used in this node.
 * @throws IgniteCheckedException if failed.
 */
@NotNull private PdsFolderSettings generateAndLockNewDbStorage(final File pstStoreBasePath,
    final int nodeIdx) throws IgniteCheckedException {

    final UUID uuid = UUID.randomUUID();
    final String consIdBasedFolder = genNewStyleSubfolderName(nodeIdx, uuid);
    final File newRandomFolder = U.resolveWorkDirectory(pstStoreBasePath.getAbsolutePath(), consIdBasedFolder, false); //mkdir here
    final GridCacheDatabaseSharedManager.FileLockHolder fileLockHolder = tryLock(newRandomFolder);

    if (fileLockHolder != null) {
        if (log.isInfoEnabled())
            log.info("Successfully created new persistent storage folder [" + newRandomFolder + "]");

        return new PdsFolderSettings(pstStoreBasePath, consIdBasedFolder, uuid, fileLockHolder, false);
    }
    throw new IgniteCheckedException("Unable to lock file generated randomly [" + newRandomFolder + "]");
}
 
开发者ID:apache,项目名称:ignite,代码行数:25,代码来源:PdsConsistentIdProcessor.java

示例2: resolvePersistentStoreBasePath

import org.apache.ignite.internal.util.typedef.internal.U; //导入方法依赖的package包/类
/**
 * @return DB storage absolute root path resolved as 'db' folder in Ignite work dir (by default) or using persistent
 * store configuration. Null if persistence is not enabled. Returned folder is created automatically.
 * @throws IgniteCheckedException if I/O failed.
 */
@Nullable private File resolvePersistentStoreBasePath() throws IgniteCheckedException {
    final DataStorageConfiguration dsCfg = cfg.getDataStorageConfiguration();

    if (dsCfg == null)
        return null;

    final String pstPath = dsCfg.getStoragePath();

    return U.resolveWorkDirectory(
        cfg.getWorkDirectory(),
        pstPath != null ? pstPath : DB_DEFAULT_FOLDER,
        false
    );

}
 
开发者ID:apache,项目名称:ignite,代码行数:21,代码来源:PdsConsistentIdProcessor.java

示例3: initDirectory

import org.apache.ignite.internal.util.typedef.internal.U; //导入方法依赖的package包/类
/**
 * Creates a directory specified by the given arguments.
 *
 * @param cfg Configured directory path, may be {@code null}.
 * @param defDir Default directory path, will be used if cfg is {@code null}.
 * @param consId Local node consistent ID.
 * @param msg File description to print out on successful initialization.
 * @return Initialized directory.
 * @throws IgniteCheckedException If failed to initialize directory.
 */
private File initDirectory(String cfg, String defDir, String consId, String msg) throws IgniteCheckedException {
    File dir;

    if (cfg != null) {
        File workDir0 = new File(cfg);

        dir = workDir0.isAbsolute() ?
            new File(workDir0, consId) :
            new File(U.resolveWorkDirectory(igCfg.getWorkDirectory(), cfg, false), consId);
    }
    else
        dir = new File(U.resolveWorkDirectory(igCfg.getWorkDirectory(), defDir, false), consId);

    U.ensureDirectory(dir, msg, log);

    return dir;
}
 
开发者ID:apache,项目名称:ignite,代码行数:28,代码来源:FileWriteAheadLogManager.java

示例4: memory

import org.apache.ignite.internal.util.typedef.internal.U; //导入方法依赖的package包/类
/**
 * @return Page memory implementation.
 * @throws Exception If failed.
 */
protected PageMemory memory() throws Exception {
    File memDir = U.resolveWorkDirectory(U.defaultWorkDirectory(), "pagemem", false);

    DataRegionConfiguration plcCfg = new DataRegionConfiguration()
        .setMaxSize(MAX_MEMORY_SIZE).setInitialSize(MAX_MEMORY_SIZE);

    DirectMemoryProvider provider = new MappedFileMemoryProvider(log(), memDir);

    return new PageMemoryNoStoreImpl(
        log(),
        provider,
        null,
        PAGE_SIZE,
        plcCfg,
        new DataRegionMetricsImpl(plcCfg),
        true);
}
 
开发者ID:apache,项目名称:ignite,代码行数:22,代码来源:PageMemoryNoLoadSelfTest.java

示例5: prepareMarshallerFileStore

import org.apache.ignite.internal.util.typedef.internal.U; //导入方法依赖的package包/类
/**
 *
 */
private void prepareMarshallerFileStore() throws Exception {
    String typeName = SimpleValue.class.getName();
    int typeId = typeName.toLowerCase().hashCode();

    String fileName = typeId + ".classname0";

    File marshStoreDir = U.resolveWorkDirectory(U.defaultWorkDirectory(), "marshaller", false);

    try(FileOutputStream out = new FileOutputStream(new File(marshStoreDir, fileName))) {
        try (Writer writer = new OutputStreamWriter(out, StandardCharsets.UTF_8)) {
            writer.write(typeName);

            writer.flush();
        }
    }
}
 
开发者ID:apache,项目名称:ignite,代码行数:20,代码来源:IgniteMarshallerCacheFSRestoreTest.java

示例6: start

import org.apache.ignite.internal.util.typedef.internal.U; //导入方法依赖的package包/类
/** {@inheritDoc} */
@Override public void start(HadoopContext ctx) throws IgniteCheckedException {
    this.ctx = ctx;

    log = ctx.kernalContext().log(HadoopExternalTaskExecutor.class);

    outputBase = U.resolveWorkDirectory(ctx.kernalContext().config().getWorkDirectory(), "hadoop", false);

    pathSep = System.getProperty("path.separator", U.isWindows() ? ";" : ":");

    initJavaCommand();

    comm = new HadoopExternalCommunication(
        ctx.localNodeId(),
        UUID.randomUUID(),
        ctx.kernalContext().config().getMarshaller(),
        log,
        ctx.kernalContext().getSystemExecutorService(),
        ctx.kernalContext().igniteInstanceName(),
        ctx.kernalContext().config().getWorkDirectory());

    comm.setListener(new MessageListener());

    comm.start();

    nodeDesc = comm.localProcessDescriptor();

    ctx.kernalContext().ports().registerPort(nodeDesc.tcpPort(), IgnitePortProtocol.TCP,
        HadoopExternalTaskExecutor.class);

    if (nodeDesc.sharedMemoryPort() != -1)
        ctx.kernalContext().ports().registerPort(nodeDesc.sharedMemoryPort(), IgnitePortProtocol.TCP,
            HadoopExternalTaskExecutor.class);

    jobTracker = ctx.jobTracker();
}
 
开发者ID:apache,项目名称:ignite,代码行数:37,代码来源:HadoopExternalTaskExecutor.java

示例7: startJavaProcess

import org.apache.ignite.internal.util.typedef.internal.U; //导入方法依赖的package包/类
/**
 * Builds process from metadata.
 *
 * @param childProcId Child process ID.
 * @param startMeta Metadata.
 * @param job Job.
 * @param igniteWorkDir Work directory.
 * @return Started process.
 */
private Process startJavaProcess(UUID childProcId, HadoopExternalTaskMetadata startMeta,
    HadoopJobEx job, String igniteWorkDir) throws Exception {
    String outFldr = jobWorkFolder(job.id()) + File.separator + childProcId;

    if (log.isDebugEnabled())
        log.debug("Will write process log output to: " + outFldr);

    List<String> cmd = new ArrayList<>();

    File workDir = U.resolveWorkDirectory(igniteWorkDir, "", false);

    cmd.add(javaCmd);
    cmd.addAll(startMeta.jvmOptions());
    cmd.add("-cp");
    cmd.add(buildClasspath(startMeta.classpath()));
    cmd.add(HadoopExternalProcessStarter.class.getName());
    cmd.add("-cpid");
    cmd.add(String.valueOf(childProcId));
    cmd.add("-ppid");
    cmd.add(String.valueOf(nodeDesc.processId()));
    cmd.add("-nid");
    cmd.add(String.valueOf(nodeDesc.parentNodeId()));
    cmd.add("-addr");
    cmd.add(nodeDesc.address());
    cmd.add("-tport");
    cmd.add(String.valueOf(nodeDesc.tcpPort()));
    cmd.add("-sport");
    cmd.add(String.valueOf(nodeDesc.sharedMemoryPort()));
    cmd.add("-out");
    cmd.add(outFldr);
    cmd.add("-wd");
    cmd.add(workDir.getAbsolutePath());

    return new ProcessBuilder(cmd)
        .redirectErrorStream(true)
        .directory(workDir)
        .start();
}
 
开发者ID:apache,项目名称:ignite,代码行数:48,代码来源:HadoopExternalTaskExecutor.java

示例8: BinaryMetadataFileStore

import org.apache.ignite.internal.util.typedef.internal.U; //导入方法依赖的package包/类
/**
 * @param metadataLocCache Metadata locale cache.
 * @param ctx Context.
 * @param log Logger.
 * @param binaryMetadataFileStoreDir Path to binary metadata store configured by user, should include binary_meta and consistentId
 */
BinaryMetadataFileStore(
    final ConcurrentMap<Integer, BinaryMetadataHolder> metadataLocCache,
    final GridKernalContext ctx,
    final IgniteLogger log,
    @Nullable final File binaryMetadataFileStoreDir
) throws IgniteCheckedException {
    this.metadataLocCache = metadataLocCache;
    this.ctx = ctx;
    this.log = log;

    if (!CU.isPersistenceEnabled(ctx.config()))
        return;

    if (binaryMetadataFileStoreDir != null)
        workDir = binaryMetadataFileStoreDir;
    else {
        final String subFolder = ctx.pdsFolderResolver().resolveFolders().folderName();

        workDir = new File(U.resolveWorkDirectory(
            ctx.config().getWorkDirectory(),
            "binary_meta",
            false
        ),
            subFolder);
    }

    U.ensureDirectory(workDir, "directory for serialized binary metadata", log);
}
 
开发者ID:apache,项目名称:ignite,代码行数:35,代码来源:BinaryMetadataFileStore.java

示例9: createWalIteratorFactory

import org.apache.ignite.internal.util.typedef.internal.U; //导入方法依赖的package包/类
/**
 * @param workDir Work directory.
 * @param subfolderName Subfolder name.
 * @return WAL iterator factory.
 * @throws IgniteCheckedException If failed.
 */
@NotNull private IgniteWalIteratorFactory createWalIteratorFactory(
    final String workDir,
    final String subfolderName
) throws IgniteCheckedException {
    final File binaryMeta = U.resolveWorkDirectory(workDir, "binary_meta", false);
    final File binaryMetaWithConsId = new File(binaryMeta, subfolderName);
    final File marshallerMapping = U.resolveWorkDirectory(workDir, "marshaller", false);

    return new IgniteWalIteratorFactory(log,
        PAGE_SIZE,
        binaryMetaWithConsId,
        marshallerMapping,
        false);
}
 
开发者ID:apache,项目名称:ignite,代码行数:21,代码来源:IgniteWalReaderTest.java

示例10: testJobRun

import org.apache.ignite.internal.util.typedef.internal.U; //导入方法依赖的package包/类
/**
 * @throws Exception If failed.
 */
public void testJobRun() throws Exception {
    for (int i = 0; i < 5; i++) {
        U.resolveWorkDirectory(U.defaultWorkDirectory(), "marshaller", true);

        log.info("Iteration: " + i);

        final int NODES = 3;

        startGridsMultiThreaded(NODES);

        client = true;

        startGrid(NODES);

        client = false;

        final IgniteInternalFuture fut = GridTestUtils.runAsync(new Callable<Void>() {
            @Override public Void call() throws Exception {
                for (int i = 0; i < 3; i++) {
                    startGrid(NODES + 1);

                    U.sleep(1000);

                    stopGrid(NODES + 1);
                }

                return null;
            }
        });

        GridTestUtils.runMultiThreaded(new IgniteInClosure<Integer>() {
            @Override public void apply(Integer integer) {
                Ignite ignite = ignite(integer % 4);

                while (!fut.isDone()) {
                    for (int i = 0; i < 10; i++)
                        ignite.compute().broadcast(job(i));
                }
            }
        }, (NODES + 1) * 5, "test");

        stopAllGrids();
    }
}
 
开发者ID:apache,项目名称:ignite,代码行数:48,代码来源:MarshallerCacheJobRunNodeRestartTest.java

示例11: MarshallerMappingFileStore

import org.apache.ignite.internal.util.typedef.internal.U; //导入方法依赖的package包/类
/**
 * @param igniteWorkDir Ignite work directory
 * @param log Logger.
 */
MarshallerMappingFileStore(String igniteWorkDir, IgniteLogger log) throws IgniteCheckedException {
    workDir = U.resolveWorkDirectory(igniteWorkDir, "marshaller", false);
    this.log = log;
}
 
开发者ID:apache,项目名称:ignite,代码行数:9,代码来源:MarshallerMappingFileStore.java

示例12: start

import org.apache.ignite.internal.util.typedef.internal.U; //导入方法依赖的package包/类
/** {@inheritDoc} */
@Override public void start() throws IgniteCheckedException {
    IpcSharedMemoryNativeLoader.load(log);

    pid = IpcSharedMemoryUtils.pid();

    if (pid == -1)
        throw new IpcEndpointBindException("Failed to get PID of the current process.");

    if (size <= 0)
        throw new IpcEndpointBindException("Space size should be positive: " + size);

    String tokDirPath = this.tokDirPath;

    if (F.isEmpty(tokDirPath))
        throw new IpcEndpointBindException("Token directory path is empty.");

    tokDirPath = tokDirPath + '/' + locNodeId.toString() + '-' + IpcSharedMemoryUtils.pid();

    tokDir = U.resolveWorkDirectory(workDir, tokDirPath, false);

    if (port <= 0 || port >= 0xffff)
        throw new IpcEndpointBindException("Port value is illegal: " + port);

    try {
        srvSock = new ServerSocket();

        // Always bind to loopback.
        srvSock.bind(new InetSocketAddress("127.0.0.1", port));
    }
    catch (IOException e) {
        // Although empty socket constructor never throws exception, close it just in case.
        U.closeQuiet(srvSock);

        throw new IpcEndpointBindException("Failed to bind shared memory IPC endpoint (is port already " +
            "in use?): " + port, e);
    }

    gcWorker = new GcWorker(igniteInstanceName, "ipc-shmem-gc", log);

    new IgniteThread(gcWorker).start();

    if (log.isInfoEnabled())
        log.info("IPC shared memory server endpoint started [port=" + port +
            ", tokDir=" + tokDir.getAbsolutePath() + ']');
}
 
开发者ID:apache,项目名称:ignite,代码行数:47,代码来源:IpcSharedMemoryServerEndpoint.java

示例13: beforeTestsStarted

import org.apache.ignite.internal.util.typedef.internal.U; //导入方法依赖的package包/类
/**
 * Called before execution of all test methods in class.
 *
 * @throws Exception If failed. {@link #afterTestsStopped()} will be called in this case.
 */
protected void beforeTestsStarted() throws Exception {
    // Will clean and re-create marshaller directory from scratch.
    U.resolveWorkDirectory(U.defaultWorkDirectory(), "marshaller", true);
    U.resolveWorkDirectory(U.defaultWorkDirectory(), "binary_meta", true);
}
 
开发者ID:apache,项目名称:ignite,代码行数:11,代码来源:GridAbstractTest.java

示例14: beforeTestsStarted

import org.apache.ignite.internal.util.typedef.internal.U; //导入方法依赖的package包/类
/** {@inheritDoc} */
@Override protected void beforeTestsStarted() throws Exception {
    allocationPath = U.resolveWorkDirectory(U.defaultWorkDirectory(), "pagemem", false);
}
 
开发者ID:apache,项目名称:ignite,代码行数:5,代码来源:IndexStorageSelfTest.java

示例15: testFillWalAndReadRecords

import org.apache.ignite.internal.util.typedef.internal.U; //导入方法依赖的package包/类
/**
 * @throws Exception if failed.
 */
public void testFillWalAndReadRecords() throws Exception {
    final int cacheObjectsToWrite = 10000;

    final Ignite ignite0 = startGrid("node0");

    ignite0.active(true);

    final Serializable consistentId = (Serializable)ignite0.cluster().localNode().consistentId();
    final String subfolderName = genNewStyleSubfolderName(0, (UUID)consistentId);

    putDummyRecords(ignite0, cacheObjectsToWrite);

    stopGrid("node0");

    final String workDir = U.defaultWorkDirectory();
    final File db = U.resolveWorkDirectory(workDir, DFLT_STORE_DIR, false);
    final File wal = new File(db, "wal");
    final File walArchive = new File(wal, "archive");

    final MockWalIteratorFactory mockItFactory = new MockWalIteratorFactory(log, PAGE_SIZE, consistentId, subfolderName, WAL_SEGMENTS);
    final WALIterator it = mockItFactory.iterator(wal, walArchive);
    final int cntUsingMockIter = iterateAndCount(it, false);

    log.info("Total records loaded " + cntUsingMockIter);
    assertTrue(cntUsingMockIter > 0);
    assertTrue(cntUsingMockIter > cacheObjectsToWrite);

    final File walArchiveDirWithConsistentId = new File(walArchive, subfolderName);
    final File walWorkDirWithConsistentId = new File(wal, subfolderName);
    final IgniteWalIteratorFactory factory = createWalIteratorFactory(workDir, subfolderName);
    final int cntArchiveDir = iterateAndCount(factory.iteratorArchiveDirectory(walArchiveDirWithConsistentId));

    log.info("Total records loaded using directory : " + cntArchiveDir);

    final int cntArchiveFileByFile = iterateAndCount(
        factory.iteratorArchiveFiles(
            walArchiveDirWithConsistentId.listFiles(FileWriteAheadLogManager.WAL_SEGMENT_FILE_FILTER)));

    log.info("Total records loaded using archive directory (file-by-file): " + cntArchiveFileByFile);

    assertTrue(cntArchiveFileByFile > cacheObjectsToWrite);
    assertTrue(cntArchiveDir > cacheObjectsToWrite);
    assertTrue(cntArchiveDir == cntArchiveFileByFile);
    //really count2 may be less because work dir correct loading is not supported yet
    assertTrue("Mock based reader loaded " + cntUsingMockIter + " records " +
            "but standalone has loaded only " + cntArchiveDir,
        cntUsingMockIter >= cntArchiveDir);

    final File[] workFiles = walWorkDirWithConsistentId.listFiles(FileWriteAheadLogManager.WAL_SEGMENT_FILE_FILTER);

    final int cntWork = iterateAndCount(factory.iteratorWorkFiles(workFiles));

    log.info("Total records loaded from work: " + cntWork);

    assertTrue("Work iterator loaded [" + cntWork + "] " +
            "Archive iterator loaded [" + cntArchiveFileByFile + "]; " +
            "mock iterator [" + cntUsingMockIter + "]",
        cntWork + cntArchiveFileByFile == cntUsingMockIter);
}
 
开发者ID:apache,项目名称:ignite,代码行数:63,代码来源:IgniteWalReaderTest.java


注:本文中的org.apache.ignite.internal.util.typedef.internal.U.resolveWorkDirectory方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。