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


Java U.maskForFileName方法代码示例

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


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

示例1: PdsFolderSettings

import org.apache.ignite.internal.util.typedef.internal.U; //导入方法依赖的package包/类
/**
 * Creates settings for compatible mode. Folder name is consistent ID (masked), no node prefix is added.
 *
 * @param persistentStoreRootPath root DB path.
 * @param consistentId node consistent ID.
 */
public PdsFolderSettings(
    @Nullable final File persistentStoreRootPath,
    @NotNull final Serializable consistentId) {

    this.consistentId = consistentId;
    this.compatible = true;
    this.folderName = U.maskForFileName(consistentId.toString());
    this.persistentStoreRootPath = persistentStoreRootPath;
    this.fileLockHolder = null;
}
 
开发者ID:apache,项目名称:ignite,代码行数:17,代码来源:PdsFolderSettings.java

示例2: pdsFolderResolver

import org.apache.ignite.internal.util.typedef.internal.U; //导入方法依赖的package包/类
/** {@inheritDoc} */
@Override public PdsFoldersResolver pdsFolderResolver() {
    return new PdsFoldersResolver() {
        /** {@inheritDoc} */
        @Override public PdsFolderSettings resolveFolders() {
            return new PdsFolderSettings(new File("."), U.maskForFileName(""));
        }
    };
}
 
开发者ID:apache,项目名称:ignite,代码行数:10,代码来源:StandaloneGridKernalContext.java

示例3: prepareNewSettings

import org.apache.ignite.internal.util.typedef.internal.U; //导入方法依赖的package包/类
/**
 * Creates new settings when we don't have cached one.
 *
 * @return new settings with prelocked directory (if appropriate).
 * @throws IgniteCheckedException if IO failed.
 */
private PdsFolderSettings prepareNewSettings() throws IgniteCheckedException {
    final File pstStoreBasePath = resolvePersistentStoreBasePath();
    //here deprecated method is used to get compatible version of consistentId
    final Serializable consistentId = ctx.discovery().consistentId();

    if (!CU.isPersistenceEnabled(cfg))
        return compatibleResolve(pstStoreBasePath, consistentId);

    if (ctx.clientNode())
        return new PdsFolderSettings(pstStoreBasePath, UUID.randomUUID());

    if (getBoolean(IGNITE_DATA_STORAGE_FOLDER_BY_CONSISTENT_ID, false))
        return compatibleResolve(pstStoreBasePath, consistentId);

    // compatible mode from configuration is used fot this case
    if (cfg.getConsistentId() != null) {
        // compatible mode from configuration is used fot this case, no locking, no consistent id change
        return new PdsFolderSettings(pstStoreBasePath, cfg.getConsistentId());
    }
    // The node scans the work directory and checks if there is a folder matching the consistent ID.
    // If such a folder exists, we start up with this ID (compatibility mode)
    final String subFolder = U.maskForFileName(consistentId.toString());

    final GridCacheDatabaseSharedManager.FileLockHolder oldStyleFolderLockHolder = tryLock(new File(pstStoreBasePath, subFolder));

    if (oldStyleFolderLockHolder != null)
        return new PdsFolderSettings(pstStoreBasePath,
            subFolder,
            consistentId,
            oldStyleFolderLockHolder,
            true);

    final File[] oldStyleFolders = pstStoreBasePath.listFiles(DB_SUBFOLDERS_OLD_STYLE_FILTER);

    if (oldStyleFolders != null && oldStyleFolders.length != 0) {
        for (File folder : oldStyleFolders) {
            final String path = getPathDisplayableInfo(folder);

            U.warn(log, "There is other non-empty storage folder under storage base directory [" + path + "]");
        }
    }

    for (FolderCandidate next : getNodeIndexSortedCandidates(pstStoreBasePath)) {
        final GridCacheDatabaseSharedManager.FileLockHolder fileLockHolder = tryLock(next.subFolderFile());

        if (fileLockHolder != null) {
            if (log.isInfoEnabled())
                log.info("Successfully locked persistence storage folder [" + next.subFolderFile() + "]");

            return new PdsFolderSettings(pstStoreBasePath,
                next.subFolderFile().getName(),
                next.uuid(),
                fileLockHolder,
                false);
        }
    }

    // was not able to find free slot, allocating new
    final GridCacheDatabaseSharedManager.FileLockHolder rootDirLock = lockRootDirectory(pstStoreBasePath);

    try {
        final List<FolderCandidate> sortedCandidates = getNodeIndexSortedCandidates(pstStoreBasePath);
        final int nodeIdx = sortedCandidates.isEmpty() ? 0 : (sortedCandidates.get(sortedCandidates.size() - 1).nodeIndex() + 1);

        return generateAndLockNewDbStorage(pstStoreBasePath, nodeIdx);
    }
    finally {
        rootDirLock.release();
        rootDirLock.close();
    }
}
 
开发者ID:apache,项目名称:ignite,代码行数:78,代码来源:PdsConsistentIdProcessor.java

示例4: testOldStyleNodeWithUnexpectedPort

import org.apache.ignite.internal.util.typedef.internal.U; //导入方法依赖的package包/类
/**
 * Test case If there are no matching folders,
 * but the directory contains old-style consistent IDs.
 * Ignite should print out a warning.
 *
 * @throws Exception if failed.
 */
public void testOldStyleNodeWithUnexpectedPort() throws Exception {
    this.configuredConsistentId = "127.0.0.1:49999"; //emulated old-style node with not appropriate consistent ID
    final Ignite ignite = startActivateFillDataGrid(0);
    final IgniteCache<Object, Object> second = ignite.getOrCreateCache("second");

    final int entries = 100;

    for (int i = 0; i < entries; i++)
        second.put((int)(Math.random() * entries), getClass().getName());

    final String prevVerFolder = U.maskForFileName(ignite.cluster().localNode().consistentId().toString());
    final String path = new File(new File(U.defaultWorkDirectory(), "db"), prevVerFolder).getCanonicalPath();

    assertPdsDirsDefaultExist(prevVerFolder);
    stopAllGrids();

    this.configuredConsistentId = null;
    this.strLog = new GridStringLogger();
    startActivateGrid(0);
    assertNodeIndexesInFolder(0); //one 0 index folder is created

    final String wholeNodeLog = strLog.toString();
    stopAllGrids();

    String foundWarning = null;
    for (String line : wholeNodeLog.split("\n")) {
        if (line.contains("There is other non-empty storage folder under storage base directory")) {
            foundWarning = line;
            break;
        }
    }

    if (foundWarning != null)
        log.info("\nWARNING generated successfully [\n" + foundWarning + "\n]");

    assertTrue("Expected to warn user on existence of old style path",
        foundWarning != null);

    assertTrue("Expected to warn user on existence of old style path [" + path + "]",
        foundWarning.contains(path));

    assertTrue("Expected to print some size for [" + path + "]",
        Pattern.compile(" [0-9]* bytes").matcher(foundWarning).find());

    strLog = null;
    startActivateGrid(0);
    assertNodeIndexesInFolder(0); //one 0 index folder is created
    stopAllGrids();
}
 
开发者ID:apache,项目名称:ignite,代码行数:57,代码来源:IgniteUidAsConsistentIdMigrationTest.java


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