use of org.neo4j.kernel.impl.store.StoreType in project neo4j by neo4j.
the class DumpStore method dumpFile.
private static void dumpFile(Function<File, StoreFactory> createStoreFactory, String fileName) throws Exception {
File file = new File(fileName);
// null means all possible ids
long[] ids = null;
if (file.isFile()) {
/* If file exists, even with : in its path, then accept it straight off. */
} else if (!file.isDirectory() && file.getName().indexOf(':') != -1) {
/* Now we know that it is not a directory either, and that the last component
of the path contains a colon, thus it is very likely an attempt to use the
id-specifying syntax. */
int idStart = fileName.lastIndexOf(':');
String[] idStrings = fileName.substring(idStart + 1).split(",");
ids = new long[idStrings.length];
for (int i = 0; i < ids.length; i++) {
ids[i] = Long.parseLong(idStrings[i]);
}
file = new File(fileName.substring(0, idStart));
if (!file.isFile()) {
throw new IllegalArgumentException("No such file: " + fileName);
}
}
StoreType storeType = StoreType.typeOf(file.getName()).orElseThrow(() -> new IllegalArgumentException("Not a store file: " + fileName));
try (NeoStores neoStores = createStoreFactory.apply(file).openNeoStores(storeType)) {
switch(storeType) {
case META_DATA:
dumpMetaDataStore(neoStores);
break;
case NODE:
dumpNodeStore(neoStores, ids);
break;
case RELATIONSHIP:
dumpRelationshipStore(neoStores, ids);
break;
case PROPERTY:
dumpPropertyStore(neoStores, ids);
break;
case SCHEMA:
dumpSchemaStore(neoStores, ids);
break;
case PROPERTY_KEY_TOKEN:
dumpPropertyKeys(neoStores, ids);
break;
case LABEL_TOKEN:
dumpLabels(neoStores, ids);
break;
case RELATIONSHIP_TYPE_TOKEN:
dumpRelationshipTypes(neoStores, ids);
break;
case RELATIONSHIP_GROUP:
dumpRelationshipGroups(neoStores, ids);
break;
default:
throw new IllegalArgumentException("Unsupported store type: " + storeType);
}
}
}
use of org.neo4j.kernel.impl.store.StoreType in project neo4j by neo4j.
the class RecordStorageEngine method listStorageFiles.
@Override
public Collection<StoreFileMetadata> listStorageFiles() {
List<StoreFileMetadata> files = new ArrayList<>();
for (StoreType type : StoreType.values()) {
if (type.equals(StoreType.COUNTS)) {
addCountStoreFiles(files);
} else {
final RecordStore<AbstractBaseRecord> recordStore = neoStores.getRecordStore(type);
StoreFileMetadata metadata = new StoreFileMetadata(recordStore.getStorageFileName(), Optional.of(type), recordStore.getRecordSize());
files.add(metadata);
}
}
return files;
}
use of org.neo4j.kernel.impl.store.StoreType in project neo4j by neo4j.
the class DirectRecordStoreMigrator method migrate.
public void migrate(File fromStoreDir, RecordFormats fromFormat, File toStoreDir, RecordFormats toFormat, MigrationProgressMonitor.Section progressMonitor, StoreType[] types, StoreType... additionalTypesToOpen) {
StoreType[] storesToOpen = ArrayUtil.concat(types, additionalTypesToOpen);
progressMonitor.start(storesToOpen.length);
try (NeoStores fromStores = new StoreFactory(fromStoreDir, config, new DefaultIdGeneratorFactory(fs), pageCache, fs, fromFormat, NullLogProvider.getInstance()).openNeoStores(true, storesToOpen);
NeoStores toStores = new StoreFactory(toStoreDir, withPersistedStoreHeadersAsConfigFrom(fromStores, storesToOpen), new DefaultIdGeneratorFactory(fs), pageCache, fs, toFormat, NullLogProvider.getInstance()).openNeoStores(true, storesToOpen)) {
for (StoreType type : types) {
// This condition will exclude counts store first and foremost.
if (type.isRecordStore()) {
migrate(fromStores.getRecordStore(type), toStores.getRecordStore(type));
progressMonitor.progress(1);
}
}
}
}
use of org.neo4j.kernel.impl.store.StoreType in project neo4j by neo4j.
the class NeoStoreFileListingTest method expectedStoreFiles.
private Set<String> expectedStoreFiles(boolean includeLogFiles) {
Set<String> storeFileNames = new HashSet<>();
for (StoreType type : StoreType.values()) {
if (!type.equals(StoreType.COUNTS)) {
storeFileNames.add(type.getStoreFile().fileName(StoreFileType.STORE));
}
}
if (includeLogFiles) {
storeFileNames.add(PhysicalLogFile.DEFAULT_NAME + ".0");
}
storeFileNames.add(IndexConfigStore.INDEX_DB_FILE_NAME);
return storeFileNames;
}
use of org.neo4j.kernel.impl.store.StoreType in project neo4j by neo4j.
the class NeoStoreFileListingTest method shouldListNeostoreDbLast.
@Test
public void shouldListNeostoreDbLast() throws Exception {
Boolean[] foundStoreType = new Boolean[StoreType.values().length];
boolean foundTxLogs = false;
final ResourceIterator<StoreFileMetadata> storeFiles = neoStoreDataSource.listStoreFiles(true);
while (storeFiles.hasNext()) {
final StoreFileMetadata storeFile = storeFiles.next();
if (storeFile.storeType().isPresent()) {
StoreType storeType = storeFile.storeType().get();
foundStoreType[storeType.ordinal()] = true;
if (storeType == StoreType.META_DATA) {
Arrays.stream(foundStoreType).forEach(Assert::assertTrue);
assertTrue("Transaction logs was not listed before neostore.db", foundTxLogs);
}
} else if (transactionLogFile(storeFile.file().getName())) {
foundTxLogs = true;
}
}
}
Aggregations