本文整理汇总了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;
}
示例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(""));
}
};
}
示例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();
}
}
示例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();
}