Search in sources :

Example 21 with Function

use of java.util.function.Function in project neo4j by neo4j.

the class LabelsAcceptanceTest method beansAPIWithNoMoreLabelIds.

@SuppressWarnings("deprecation")
private GraphDatabaseService beansAPIWithNoMoreLabelIds() {
    final EphemeralIdGenerator.Factory idFactory = new EphemeralIdGenerator.Factory() {

        private IdTypeConfigurationProvider idTypeConfigurationProvider = new CommunityIdTypeConfigurationProvider();

        @Override
        public IdGenerator open(File fileName, int grabSize, IdType idType, long highId, long maxId) {
            if (idType == IdType.LABEL_TOKEN) {
                IdGenerator generator = generators.get(idType);
                if (generator == null) {
                    IdTypeConfiguration idTypeConfiguration = idTypeConfigurationProvider.getIdTypeConfiguration(idType);
                    generator = new EphemeralIdGenerator(idType, idTypeConfiguration) {

                        @Override
                        public long nextId() {
                            // Same exception as the one thrown by IdGeneratorImpl
                            throw new UnderlyingStorageException("Id capacity exceeded");
                        }
                    };
                    generators.put(idType, generator);
                }
                return generator;
            }
            return super.open(fileName, grabSize, idType, Long.MAX_VALUE, Long.MAX_VALUE);
        }
    };
    TestGraphDatabaseFactory dbFactory = new TestGraphDatabaseFactory() {

        @Override
        protected GraphDatabaseBuilder.DatabaseCreator createImpermanentDatabaseCreator(final File storeDir, final TestGraphDatabaseFactoryState state) {
            return new GraphDatabaseBuilder.DatabaseCreator() {

                @Override
                public GraphDatabaseService newDatabase(Map<String, String> config) {
                    return newDatabase(Config.embeddedDefaults(config));
                }

                @Override
                public GraphDatabaseService newDatabase(@Nonnull Config config) {
                    return new ImpermanentGraphDatabase(storeDir, config, GraphDatabaseDependencies.newDependencies(state.databaseDependencies())) {

                        @Override
                        protected void create(File storeDir, Config config, GraphDatabaseFacadeFactory.Dependencies dependencies) {
                            Function<PlatformModule, EditionModule> factory = (platformModule) -> new CommunityEditionModule(platformModule) {

                                @Override
                                protected IdGeneratorFactory createIdGeneratorFactory(FileSystemAbstraction fs, IdTypeConfigurationProvider idTypeConfigurationProvider) {
                                    return idFactory;
                                }
                            };
                            new GraphDatabaseFacadeFactory(DatabaseInfo.COMMUNITY, factory) {

                                @Override
                                protected PlatformModule createPlatform(File storeDir, Config config, Dependencies dependencies, GraphDatabaseFacade graphDatabaseFacade) {
                                    return new ImpermanentPlatformModule(storeDir, config, databaseInfo, dependencies, graphDatabaseFacade);
                                }
                            }.initFacade(storeDir, config, dependencies, this);
                        }
                    };
                }
            };
        }
    };
    return dbFactory.newImpermanentDatabase();
}
Also used : EphemeralIdGenerator(org.neo4j.test.impl.EphemeralIdGenerator) IdGeneratorFactory(org.neo4j.kernel.impl.store.id.IdGeneratorFactory) GraphDatabaseFacadeFactory(org.neo4j.kernel.impl.factory.GraphDatabaseFacadeFactory) Matchers.not(org.hamcrest.Matchers.not) Statement(org.neo4j.kernel.api.Statement) IdTypeConfigurationProvider(org.neo4j.kernel.impl.store.id.configuration.IdTypeConfigurationProvider) Matchers.hasItems(org.hamcrest.Matchers.hasItems) TestGraphDatabaseFactory(org.neo4j.test.TestGraphDatabaseFactory) Cursor(org.neo4j.cursor.Cursor) GraphDatabaseDependencies(org.neo4j.kernel.GraphDatabaseDependencies) Assert.assertThat(org.junit.Assert.assertThat) GraphDatabaseBuilder(org.neo4j.graphdb.factory.GraphDatabaseBuilder) Iterables.map(org.neo4j.helpers.collection.Iterables.map) EditionModule(org.neo4j.kernel.impl.factory.EditionModule) Map(java.util.Map) CommunityIdTypeConfigurationProvider(org.neo4j.kernel.impl.store.id.configuration.CommunityIdTypeConfigurationProvider) Assert.fail(org.junit.Assert.fail) Neo4jMatchers.inTx(org.neo4j.test.mockito.matcher.Neo4jMatchers.inTx) Collectors.toSet(java.util.stream.Collectors.toSet) UnderlyingStorageException(org.neo4j.kernel.impl.store.UnderlyingStorageException) PrimitiveIntCollections.consume(org.neo4j.collection.primitive.PrimitiveIntCollections.consume) ThreadToStatementContextBridge(org.neo4j.kernel.impl.core.ThreadToStatementContextBridge) Set(java.util.Set) GraphDatabaseAPI(org.neo4j.kernel.internal.GraphDatabaseAPI) IdType(org.neo4j.kernel.impl.store.id.IdType) List(java.util.List) Stream(java.util.stream.Stream) Assert.assertFalse(org.junit.Assert.assertFalse) TestGraphDatabaseFactoryState(org.neo4j.test.TestGraphDatabaseFactoryState) PropertyItem(org.neo4j.storageengine.api.PropertyItem) ImpermanentGraphDatabase(org.neo4j.test.ImpermanentGraphDatabase) IdTypeConfiguration(org.neo4j.kernel.impl.store.id.configuration.IdTypeConfiguration) Iterators.asSet(org.neo4j.helpers.collection.Iterators.asSet) Neo4jMatchers.hasNoLabels(org.neo4j.test.mockito.matcher.Neo4jMatchers.hasNoLabels) CommunityEditionModule(org.neo4j.kernel.impl.factory.CommunityEditionModule) Function(java.util.function.Function) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) Neo4jMatchers.hasLabel(org.neo4j.test.mockito.matcher.Neo4jMatchers.hasLabel) Neo4jMatchers.hasNoNodes(org.neo4j.test.mockito.matcher.Neo4jMatchers.hasNoNodes) Neo4jMatchers.hasLabels(org.neo4j.test.mockito.matcher.Neo4jMatchers.hasLabels) Nonnull(javax.annotation.Nonnull) ImpermanentDatabaseRule(org.neo4j.test.rule.ImpermanentDatabaseRule) Config(org.neo4j.kernel.configuration.Config) Iterator(java.util.Iterator) DatabaseInfo(org.neo4j.kernel.impl.factory.DatabaseInfo) IdGenerator(org.neo4j.kernel.impl.store.id.IdGenerator) Assert.assertTrue(org.junit.Assert.assertTrue) Test(org.junit.Test) Label.label(org.neo4j.graphdb.Label.label) Iterables.asList(org.neo4j.helpers.collection.Iterables.asList) File(java.io.File) Rule(org.junit.Rule) Iterables(org.neo4j.helpers.collection.Iterables) Neo4jMatchers.hasNodes(org.neo4j.test.mockito.matcher.Neo4jMatchers.hasNodes) NodeItem(org.neo4j.storageengine.api.NodeItem) GraphDatabaseFacade(org.neo4j.kernel.impl.factory.GraphDatabaseFacade) PlatformModule(org.neo4j.kernel.impl.factory.PlatformModule) Assert.assertEquals(org.junit.Assert.assertEquals) FileSystemAbstraction(org.neo4j.io.fs.FileSystemAbstraction) FileSystemAbstraction(org.neo4j.io.fs.FileSystemAbstraction) Config(org.neo4j.kernel.configuration.Config) IdGeneratorFactory(org.neo4j.kernel.impl.store.id.IdGeneratorFactory) GraphDatabaseFacadeFactory(org.neo4j.kernel.impl.factory.GraphDatabaseFacadeFactory) TestGraphDatabaseFactory(org.neo4j.test.TestGraphDatabaseFactory) EphemeralIdGenerator(org.neo4j.test.impl.EphemeralIdGenerator) GraphDatabaseFacadeFactory(org.neo4j.kernel.impl.factory.GraphDatabaseFacadeFactory) TestGraphDatabaseFactory(org.neo4j.test.TestGraphDatabaseFactory) GraphDatabaseDependencies(org.neo4j.kernel.GraphDatabaseDependencies) IdTypeConfigurationProvider(org.neo4j.kernel.impl.store.id.configuration.IdTypeConfigurationProvider) CommunityIdTypeConfigurationProvider(org.neo4j.kernel.impl.store.id.configuration.CommunityIdTypeConfigurationProvider) GraphDatabaseBuilder(org.neo4j.graphdb.factory.GraphDatabaseBuilder) CommunityEditionModule(org.neo4j.kernel.impl.factory.CommunityEditionModule) TestGraphDatabaseFactoryState(org.neo4j.test.TestGraphDatabaseFactoryState) Nonnull(javax.annotation.Nonnull) EphemeralIdGenerator(org.neo4j.test.impl.EphemeralIdGenerator) IdGenerator(org.neo4j.kernel.impl.store.id.IdGenerator) UnderlyingStorageException(org.neo4j.kernel.impl.store.UnderlyingStorageException) PlatformModule(org.neo4j.kernel.impl.factory.PlatformModule) IdType(org.neo4j.kernel.impl.store.id.IdType) EditionModule(org.neo4j.kernel.impl.factory.EditionModule) CommunityEditionModule(org.neo4j.kernel.impl.factory.CommunityEditionModule) IdTypeConfiguration(org.neo4j.kernel.impl.store.id.configuration.IdTypeConfiguration) CommunityIdTypeConfigurationProvider(org.neo4j.kernel.impl.store.id.configuration.CommunityIdTypeConfigurationProvider) ImpermanentGraphDatabase(org.neo4j.test.ImpermanentGraphDatabase) GraphDatabaseFacade(org.neo4j.kernel.impl.factory.GraphDatabaseFacade) File(java.io.File) Map(java.util.Map)

Example 22 with Function

use of java.util.function.Function in project neo4j by neo4j.

the class CheckTxLogsTest method shouldReportNoInconsistenciesIfTxIdSequenceIsStriclyIncreasingAndHasNoGaps.

@Test
public void shouldReportNoInconsistenciesIfTxIdSequenceIsStriclyIncreasingAndHasNoGaps() throws Exception {
    // given
    Function<Long, Command.NodeCommand> newNodeCommandFunction = (i) -> new Command.NodeCommand(new NodeRecord(i, false, false, -1, -1, -1), new NodeRecord(i, true, false, -1, -1, -1));
    writeTxContent(logFile(1), 40L, newNodeCommandFunction.apply(1L));
    writeTxContent(logFile(1), 41L, newNodeCommandFunction.apply(2L));
    writeTxContent(logFile(1), 42L, newNodeCommandFunction.apply(3L));
    writeTxContent(logFile(2), 43L, newNodeCommandFunction.apply(4L));
    writeTxContent(logFile(2), 44L, newNodeCommandFunction.apply(5L));
    writeTxContent(logFile(2), 45L, newNodeCommandFunction.apply(6L));
    CapturingInconsistenciesHandler handler = new CapturingInconsistenciesHandler();
    CheckTxLogs checker = new CheckTxLogs(System.out, fsRule.get());
    // when
    checker.scan(new PhysicalLogFiles(storeDirectory, fsRule.get()), handler, CHECK_TYPES);
    // then
    assertTrue(handler.txIdSequenceInconsistencies.isEmpty());
}
Also used : Arrays(java.util.Arrays) PropertyType(org.neo4j.kernel.impl.store.PropertyType) PhysicalFlushableChannel(org.neo4j.kernel.impl.transaction.log.PhysicalFlushableChannel) EphemeralFileSystemRule(org.neo4j.test.rule.fs.EphemeralFileSystemRule) LogVersionedStoreChannel(org.neo4j.kernel.impl.transaction.log.LogVersionedStoreChannel) CheckTypes(org.neo4j.tools.txlog.checktypes.CheckTypes) PROPERTY(org.neo4j.tools.txlog.checktypes.CheckTypes.PROPERTY) Function(java.util.function.Function) ArrayList(java.util.ArrayList) NEO_STORE(org.neo4j.tools.txlog.checktypes.CheckTypes.NEO_STORE) Assert.assertThat(org.junit.Assert.assertThat) LogPosition(org.neo4j.kernel.impl.transaction.log.LogPosition) Command(org.neo4j.kernel.impl.transaction.command.Command) StoreChannel(org.neo4j.io.fs.StoreChannel) LogEntryWriter(org.neo4j.kernel.impl.transaction.log.entry.LogEntryWriter) RELATIONSHIP_GROUP(org.neo4j.tools.txlog.checktypes.CheckTypes.RELATIONSHIP_GROUP) PropertyBlock(org.neo4j.kernel.impl.store.record.PropertyBlock) ThrowingConsumer(org.neo4j.function.ThrowingConsumer) Matchers.lessThan(org.hamcrest.Matchers.lessThan) PhysicalLogVersionedStoreChannel(org.neo4j.kernel.impl.transaction.log.PhysicalLogVersionedStoreChannel) PhysicalLogFiles(org.neo4j.kernel.impl.transaction.log.PhysicalLogFiles) PropertyStore(org.neo4j.kernel.impl.store.PropertyStore) CHECK_TYPES(org.neo4j.tools.txlog.checktypes.CheckTypes.CHECK_TYPES) PropertyRecord(org.neo4j.kernel.impl.store.record.PropertyRecord) Assert.assertTrue(org.junit.Assert.assertTrue) Test(org.junit.Test) IOException(java.io.IOException) LogHeaderWriter(org.neo4j.kernel.impl.transaction.log.entry.LogHeaderWriter) File(java.io.File) PhysicalLogFile(org.neo4j.kernel.impl.transaction.log.PhysicalLogFile) List(java.util.List) Rule(org.junit.Rule) RelationshipGroupRecord(org.neo4j.kernel.impl.store.record.RelationshipGroupRecord) RELATIONSHIP(org.neo4j.tools.txlog.checktypes.CheckTypes.RELATIONSHIP) Assert.assertFalse(org.junit.Assert.assertFalse) NodeRecord(org.neo4j.kernel.impl.store.record.NodeRecord) LOG_HEADER_SIZE(org.neo4j.kernel.impl.transaction.log.entry.LogHeader.LOG_HEADER_SIZE) NODE(org.neo4j.tools.txlog.checktypes.CheckTypes.NODE) NeoStoreRecord(org.neo4j.kernel.impl.store.record.NeoStoreRecord) RelationshipRecord(org.neo4j.kernel.impl.store.record.RelationshipRecord) PhysicalTransactionRepresentation(org.neo4j.kernel.impl.transaction.log.PhysicalTransactionRepresentation) TransactionLogWriter(org.neo4j.kernel.impl.transaction.log.TransactionLogWriter) SuppressOutput(org.neo4j.test.rule.SuppressOutput) Assert.assertEquals(org.junit.Assert.assertEquals) FileSystemAbstraction(org.neo4j.io.fs.FileSystemAbstraction) NodeRecord(org.neo4j.kernel.impl.store.record.NodeRecord) PhysicalLogFiles(org.neo4j.kernel.impl.transaction.log.PhysicalLogFiles) Test(org.junit.Test)

Example 23 with Function

use of java.util.function.Function in project neo4j by neo4j.

the class ReadReplicaReplicationIT method aReadReplicShouldBeAbleToRejoinTheCluster.

@Test
public void aReadReplicShouldBeAbleToRejoinTheCluster() throws Exception {
    int readReplicaId = 4;
    Cluster cluster = clusterRule.withNumberOfReadReplicas(0).startCluster();
    cluster.coreTx(createSomeData);
    cluster.addReadReplicaWithId(readReplicaId).start();
    // let's spend some time by adding more data
    cluster.coreTx(createSomeData);
    awaitEx(() -> readReplicasUpToDateAsTheLeader(cluster.awaitLeader(), cluster.readReplicas()), 1, TimeUnit.MINUTES);
    cluster.removeReadReplicaWithMemberId(readReplicaId);
    // let's spend some time by adding more data
    cluster.coreTx(createSomeData);
    cluster.addReadReplicaWithId(readReplicaId).start();
    awaitEx(() -> readReplicasUpToDateAsTheLeader(cluster.awaitLeader(), cluster.readReplicas()), 1, TimeUnit.MINUTES);
    Function<ClusterMember, DbRepresentation> toRep = db -> DbRepresentation.of(db.database());
    Set<DbRepresentation> dbs = cluster.coreMembers().stream().map(toRep).collect(toSet());
    dbs.addAll(cluster.readReplicas().stream().map(toRep).collect(toSet()));
    cluster.shutdown();
    assertEquals(1, dbs.size());
}
Also used : ResourceIterator(org.neo4j.graphdb.ResourceIterator) AvailabilityGuard(org.neo4j.kernel.AvailabilityGuard) Log(org.neo4j.logging.Log) CausalClusteringSettings(org.neo4j.causalclustering.core.CausalClusteringSettings) ReadReplicaGraphDatabase(org.neo4j.causalclustering.readreplica.ReadReplicaGraphDatabase) CoreMatchers.startsWith(org.hamcrest.CoreMatchers.startsWith) ThrowingSupplier(org.neo4j.function.ThrowingSupplier) HighLimit(org.neo4j.kernel.impl.store.format.highlimit.HighLimit) Map(java.util.Map) Is.is(org.hamcrest.core.Is.is) CoreClusterMember(org.neo4j.causalclustering.discovery.CoreClusterMember) Assert.fail(org.junit.Assert.fail) Transaction(org.neo4j.graphdb.Transaction) Path(java.nio.file.Path) Collectors.toSet(java.util.stream.Collectors.toSet) Standard(org.neo4j.kernel.impl.store.format.standard.Standard) PageCache(org.neo4j.io.pagecache.PageCache) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) Collection(java.util.Collection) Set(java.util.Set) BinaryOperator(java.util.function.BinaryOperator) UnsatisfiedDependencyException(org.neo4j.kernel.impl.util.UnsatisfiedDependencyException) Cluster(org.neo4j.causalclustering.discovery.Cluster) GraphDatabaseAPI(org.neo4j.kernel.internal.GraphDatabaseAPI) CoreGraphDatabase(org.neo4j.causalclustering.core.CoreGraphDatabase) Matchers.instanceOf(org.hamcrest.Matchers.instanceOf) TransactionIdTracker(org.neo4j.kernel.api.txtracking.TransactionIdTracker) MetaDataStore(org.neo4j.kernel.impl.store.MetaDataStore) Matchers.equalTo(org.hamcrest.Matchers.equalTo) Predicates.awaitEx(org.neo4j.function.Predicates.awaitEx) Matchers.greaterThan(org.hamcrest.Matchers.greaterThan) GraphDatabaseSettings(org.neo4j.graphdb.factory.GraphDatabaseSettings) SortedMap(java.util.SortedMap) Mockito.mock(org.mockito.Mockito.mock) Role(org.neo4j.causalclustering.core.consensus.roles.Role) ClusterMember(org.neo4j.causalclustering.discovery.ClusterMember) Label(org.neo4j.graphdb.Label) TransactionIdStore(org.neo4j.kernel.impl.transaction.log.TransactionIdStore) Iterables.count(org.neo4j.helpers.collection.Iterables.count) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) Monitors(org.neo4j.kernel.monitoring.Monitors) MINUTES(java.util.concurrent.TimeUnit.MINUTES) ClusterRule(org.neo4j.test.causalclustering.ClusterRule) LabelScanStore(org.neo4j.kernel.api.labelscan.LabelScanStore) Duration.ofSeconds(java.time.Duration.ofSeconds) Function(java.util.function.Function) Node(org.neo4j.graphdb.Node) HashSet(java.util.HashSet) CatchupPollingProcess(org.neo4j.causalclustering.catchup.tx.CatchupPollingProcess) LifecycleException(org.neo4j.kernel.lifecycle.LifecycleException) HazelcastDiscoveryServiceFactory(org.neo4j.causalclustering.discovery.HazelcastDiscoveryServiceFactory) GraphDatabaseService(org.neo4j.graphdb.GraphDatabaseService) TIME(org.neo4j.kernel.impl.store.MetaDataStore.Position.TIME) BiConsumer(java.util.function.BiConsumer) TransactionFailureException(org.neo4j.kernel.api.exceptions.TransactionFailureException) MatcherAssert.assertThat(org.hamcrest.MatcherAssert.assertThat) MapUtil.stringMap(org.neo4j.helpers.collection.MapUtil.stringMap) FileNames(org.neo4j.causalclustering.core.consensus.log.segmented.FileNames) PhysicalLogFiles(org.neo4j.kernel.impl.transaction.log.PhysicalLogFiles) FileCopyMonitor(org.neo4j.causalclustering.catchup.tx.FileCopyMonitor) Assert.assertTrue(org.junit.Assert.assertTrue) Test(org.junit.Test) IOException(java.io.IOException) Assert.assertEventually(org.neo4j.test.assertion.Assert.assertEventually) File(java.io.File) TimeUnit(java.util.concurrent.TimeUnit) DefaultFileSystemAbstraction(org.neo4j.io.fs.DefaultFileSystemAbstraction) SampleData.createData(org.neo4j.causalclustering.scenarios.SampleData.createData) Rule(org.junit.Rule) Paths(java.nio.file.Paths) WriteOperationsNotAllowedException(org.neo4j.graphdb.security.WriteOperationsNotAllowedException) GraphDatabaseFacade(org.neo4j.kernel.impl.factory.GraphDatabaseFacade) DbRepresentation(org.neo4j.test.DbRepresentation) Clock(java.time.Clock) ReadReplica(org.neo4j.causalclustering.discovery.ReadReplica) SECONDS(java.util.concurrent.TimeUnit.SECONDS) Assert.assertEquals(org.junit.Assert.assertEquals) FileSystemAbstraction(org.neo4j.io.fs.FileSystemAbstraction) CoreClusterMember(org.neo4j.causalclustering.discovery.CoreClusterMember) ClusterMember(org.neo4j.causalclustering.discovery.ClusterMember) Cluster(org.neo4j.causalclustering.discovery.Cluster) DbRepresentation(org.neo4j.test.DbRepresentation) Test(org.junit.Test)

Example 24 with Function

use of java.util.function.Function in project neo4j by neo4j.

the class LegacyIndexTransactionStateImplTest method newLegacyIndexTxState.

private static LegacyIndexTransactionStateImpl newLegacyIndexTxState() {
    IndexConfigStore indexConfigStore = mock(IndexConfigStore.class);
    when(indexConfigStore.get(eq(Node.class), anyString())).thenReturn(singletonMap(IndexManager.PROVIDER, "test"));
    when(indexConfigStore.get(eq(Relationship.class), anyString())).thenReturn(singletonMap(IndexManager.PROVIDER, "test"));
    Function<String, IndexImplementation> providerLookup = s -> mock(IndexImplementation.class);
    return new LegacyIndexTransactionStateImpl(indexConfigStore, providerLookup);
}
Also used : Arrays(java.util.Arrays) IndexDefineCommand(org.neo4j.kernel.impl.index.IndexDefineCommand) IndexImplementation(org.neo4j.kernel.spi.legacyindex.IndexImplementation) Set(java.util.Set) Test(org.junit.Test) Mockito.when(org.mockito.Mockito.when) Function(java.util.function.Function) Node(org.neo4j.graphdb.Node) Matchers.anyString(org.mockito.Matchers.anyString) StorageCommand(org.neo4j.storageengine.api.StorageCommand) HashSet(java.util.HashSet) IndexManager(org.neo4j.graphdb.index.IndexManager) IndexEntityType(org.neo4j.kernel.impl.index.IndexEntityType) Command(org.neo4j.kernel.impl.transaction.command.Command) Relationship(org.neo4j.graphdb.Relationship) IndexConfigStore(org.neo4j.kernel.impl.index.IndexConfigStore) Matchers.eq(org.mockito.Matchers.eq) IndexCommand(org.neo4j.kernel.impl.index.IndexCommand) Collections.singletonMap(java.util.Collections.singletonMap) Assert.assertEquals(org.junit.Assert.assertEquals) Mockito.mock(org.mockito.Mockito.mock) IndexImplementation(org.neo4j.kernel.spi.legacyindex.IndexImplementation) Node(org.neo4j.graphdb.Node) Relationship(org.neo4j.graphdb.Relationship) IndexConfigStore(org.neo4j.kernel.impl.index.IndexConfigStore) Matchers.anyString(org.mockito.Matchers.anyString)

Example 25 with Function

use of java.util.function.Function in project neo4j by neo4j.

the class HighlyAvailableKernelData method getClusterInfo.

public ClusterMemberInfo[] getClusterInfo() {
    List<ClusterMemberInfo> clusterMemberInfos = new ArrayList<ClusterMemberInfo>();
    Function<Object, String> nullSafeToString = from -> from == null ? "" : from.toString();
    for (ClusterMember clusterMember : memberInfo.getMembers()) {
        ClusterMemberInfo clusterMemberInfo = new ClusterMemberInfo(clusterMember.getInstanceId().toString(), clusterMember.getHAUri() != null, clusterMember.isAlive(), clusterMember.getHARole(), asArray(String.class, map(nullSafeToString, clusterMember.getRoleURIs())), asArray(String.class, map(nullSafeToString, clusterMember.getRoles())));
        clusterMemberInfos.add(clusterMemberInfo);
    }
    return clusterMemberInfos.toArray(new ClusterMemberInfo[clusterMemberInfos.size()]);
}
Also used : PageCache(org.neo4j.io.pagecache.PageCache) Lifecycle(org.neo4j.kernel.lifecycle.Lifecycle) Config(org.neo4j.kernel.configuration.Config) KernelData(org.neo4j.kernel.internal.KernelData) ClusterMemberInfo(org.neo4j.management.ClusterMemberInfo) Iterables.asArray(org.neo4j.helpers.collection.Iterables.asArray) Version(org.neo4j.kernel.internal.Version) ClusterDatabaseInfo(org.neo4j.management.ClusterDatabaseInfo) Function(java.util.function.Function) File(java.io.File) ArrayList(java.util.ArrayList) GraphDatabaseAPI(org.neo4j.kernel.internal.GraphDatabaseAPI) ClusterMembers(org.neo4j.kernel.ha.cluster.member.ClusterMembers) List(java.util.List) Iterables.map(org.neo4j.helpers.collection.Iterables.map) ClusterMember(org.neo4j.kernel.ha.cluster.member.ClusterMember) FileSystemAbstraction(org.neo4j.io.fs.FileSystemAbstraction) ClusterMember(org.neo4j.kernel.ha.cluster.member.ClusterMember) ClusterMemberInfo(org.neo4j.management.ClusterMemberInfo) ArrayList(java.util.ArrayList)

Aggregations

Function (java.util.function.Function)1261 List (java.util.List)606 Map (java.util.Map)447 ArrayList (java.util.ArrayList)416 Test (org.junit.Test)358 Collectors (java.util.stream.Collectors)324 HashMap (java.util.HashMap)287 Collections (java.util.Collections)284 Arrays (java.util.Arrays)271 Set (java.util.Set)255 IOException (java.io.IOException)252 Collection (java.util.Collection)192 HashSet (java.util.HashSet)191 TimeUnit (java.util.concurrent.TimeUnit)174 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)158 Optional (java.util.Optional)157 Assert (org.junit.Assert)137 Consumer (java.util.function.Consumer)134 Supplier (java.util.function.Supplier)126 CompletableFuture (java.util.concurrent.CompletableFuture)121