//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldConsultUnsatisfiedDependencyHandlerOnFailingDependencyClasses() public virtual void ShouldConsultUnsatisfiedDependencyHandlerOnFailingDependencyClasses() { // GIVEN KernelContext context = mock(typeof(KernelContext)); KernelExtensionFailureStrategy handler = mock(typeof(KernelExtensionFailureStrategy)); Dependencies dependencies = new Dependencies(); // that hasn't got anything. UninitializableKernelExtensionFactory extensionFactory = new UninitializableKernelExtensionFactory(); GlobalKernelExtensions extensions = new GlobalKernelExtensions(context, iterable(extensionFactory), dependencies, handler); // WHEN LifeSupport life = new LifeSupport(); life.Add(extensions); try { life.Start(); // THEN verify(handler).handle(eq(extensionFactory), any(typeof(System.ArgumentException))); } finally { life.Shutdown(); } }
public ClusteringModule(DiscoveryServiceFactory discoveryServiceFactory, MemberId myself, PlatformModule platformModule, File clusterStateDirectory, DatabaseLayout databaseLayout) { LifeSupport life = platformModule.Life; Config config = platformModule.Config; LogProvider logProvider = platformModule.Logging.InternalLogProvider; LogProvider userLogProvider = platformModule.Logging.UserLogProvider; Dependencies dependencies = platformModule.Dependencies; Monitors monitors = platformModule.Monitors; FileSystemAbstraction fileSystem = platformModule.FileSystem; RemoteMembersResolver remoteMembersResolver = chooseResolver(config, platformModule.Logging); _topologyService = discoveryServiceFactory.CoreTopologyService(config, myself, platformModule.JobScheduler, logProvider, userLogProvider, remoteMembersResolver, ResolveStrategy(config, logProvider), monitors); life.Add(_topologyService); dependencies.SatisfyDependency(_topologyService); // for tests CoreBootstrapper coreBootstrapper = new CoreBootstrapper(databaseLayout, platformModule.PageCache, fileSystem, config, logProvider, platformModule.Monitors); SimpleStorage <ClusterId> clusterIdStorage = new SimpleFileStorage <ClusterId>(fileSystem, clusterStateDirectory, CLUSTER_ID_NAME, new ClusterId.Marshal(), logProvider); SimpleStorage <DatabaseName> dbNameStorage = new SimpleFileStorage <DatabaseName>(fileSystem, clusterStateDirectory, DB_NAME, new DatabaseName.Marshal(), logProvider); string dbName = config.Get(CausalClusteringSettings.database); int minimumCoreHosts = config.Get(CausalClusteringSettings.minimum_core_cluster_size_at_formation); Duration clusterBindingTimeout = config.Get(CausalClusteringSettings.cluster_binding_timeout); _clusterBinder = new ClusterBinder(clusterIdStorage, dbNameStorage, _topologyService, Clocks.systemClock(), () => sleep(100), clusterBindingTimeout, coreBootstrapper, dbName, minimumCoreHosts, platformModule.Monitors); }
private void InstantiateKernelExtensions() { _life = new LifeSupport(); _life.start(); _labelScanStore = new NativeLabelScanStore(_pageCache, _databaseLayout, _fileSystem, Org.Neo4j.Kernel.Impl.Api.scan.FullStoreChangeStream_Fields.Empty, false, new Monitors(), RecoveryCleanupWorkCollector.immediate()); _life.add(_labelScanStore); }
public EventReporterBuilder(Config config, MetricRegistry registry, Log logger, KernelContext kernelContext, LifeSupport life, FileSystemAbstraction fileSystem, JobScheduler scheduler, ConnectorPortRegister portRegister) { this._config = config; this._registry = registry; this._logger = logger; this._kernelContext = kernelContext; this._life = life; this._fileSystem = fileSystem; this._scheduler = scheduler; this._portRegister = portRegister; }
public NetworkedServerFactory(LifeSupport life, ProtocolServerFactory protocolServerFactory, TimeoutStrategy timeoutStrategy, LogProvider logProvider, ObjectInputStreamFactory objectInputStreamFactory, ObjectOutputStreamFactory objectOutputStreamFactory, NetworkReceiver.Monitor networkReceiverMonitor, NetworkSender.Monitor networkSenderMonitor, NamedThreadFactory.Monitor namedThreadFactoryMonitor) { this._life = life; this._protocolServerFactory = protocolServerFactory; this._timeoutStrategy = timeoutStrategy; this._networkReceiverMonitor = networkReceiverMonitor; this._networkSenderMonitor = networkSenderMonitor; this._logProvider = logProvider; this._objectInputStreamFactory = objectInputStreamFactory; this._objectOutputStreamFactory = objectOutputStreamFactory; this._namedThreadFactoryMonitor = namedThreadFactoryMonitor; }
public CommunityEditionModule(PlatformModule platformModule) { Org.Neo4j.Kernel.impl.util.Dependencies dependencies = platformModule.Dependencies; Config config = platformModule.Config; LogService logging = platformModule.Logging; FileSystemAbstraction fileSystem = platformModule.FileSystem; PageCache pageCache = platformModule.PageCache; DataSourceManager dataSourceManager = platformModule.DataSourceManager; LifeSupport life = platformModule.Life; life.Add(platformModule.DataSourceManager); WatcherServiceFactoryConflict = databaseDir => CreateFileSystemWatcherService(fileSystem, databaseDir, logging, platformModule.JobScheduler, config, FileWatcherFileNameFilter()); this.AccessCapabilityConflict = config.Get(GraphDatabaseSettings.read_only) ? new ReadOnly() : new CanWrite(); dependencies.SatisfyDependency(SslPolicyLoader.create(config, logging.InternalLogProvider)); // for bolt and web server LocksFactory lockFactory = createLockFactory(config, logging); LocksSupplierConflict = () => createLockManager(lockFactory, config, platformModule.Clock); StatementLocksFactoryProviderConflict = locks => CreateStatementLocksFactory(locks, config, logging); ThreadToTransactionBridgeConflict = dependencies.SatisfyDependency(new ThreadToStatementContextBridge(GetGlobalAvailabilityGuard(platformModule.Clock, logging, platformModule.Config))); IdContextFactoryConflict = CreateIdContextFactory(platformModule, fileSystem); TokenHoldersProviderConflict = CreateTokenHolderProvider(platformModule); File kernelContextDirectory = platformModule.StoreLayout.storeDirectory(); dependencies.SatisfyDependency(CreateKernelData(fileSystem, pageCache, kernelContextDirectory, config, life, dataSourceManager)); CommitProcessFactoryConflict = new CommunityCommitProcessFactory(); HeaderInformationFactoryConflict = CreateHeaderInformationFactory(); SchemaWriteGuardConflict = CreateSchemaWriteGuard(); TransactionStartTimeoutConflict = config.Get(GraphDatabaseSettings.transaction_start_timeout).toMillis(); ConstraintSemanticsConflict = CreateSchemaRuleVerifier(); IoLimiterConflict = Org.Neo4j.Io.pagecache.IOLimiter_Fields.Unlimited; ConnectionTrackerConflict = dependencies.SatisfyDependency(CreateConnectionTracker()); PublishEditionInfo(dependencies.ResolveDependency(typeof(UsageData)), platformModule.DatabaseInfo, config); }
public static LogProvider Provider(LifeSupport life, LogProvider provider) { if (_enabled) { if (provider is NullLogProvider) { return(provider); } return(new AsyncLogProvider(life.Add(new AsyncLogging(provider.GetLog(typeof(AsyncLogging)))).eventSender(), provider)); } else { return(provider); } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shutdownWhileFinishingTransactionWithIndexUpdates() public virtual void ShutdownWhileFinishingTransactionWithIndexUpdates() { CreateConstraint(Database); WaitIndexesOnline(Database); using (Transaction transaction = Database.beginTx()) { Node node = Database.createNode(_constraintIndexLabel); node.SetProperty(UNIQUE_PROPERTY_NAME, _indexProvider.AndIncrement); DependencyResolver dependencyResolver = Database.DependencyResolver; NeoStoreDataSource dataSource = dependencyResolver.ResolveDependency(typeof(NeoStoreDataSource)); LifeSupport dataSourceLife = dataSource.Life; TransactionCloseListener closeListener = new TransactionCloseListener(transaction); dataSourceLife.AddLifecycleListener(closeListener); dataSource.Stop(); assertTrue("Transaction should be closed and no exception should be thrown.", closeListener.TransactionClosed); } }
/// <summary> /// Performs a switch to the master state. Starts communication endpoints, switches components to the master state /// and broadcasts the appropriate Master Is Available event. </summary> /// <param name="haCommunicationLife"> The LifeSupport instance to register communication endpoints. </param> /// <param name="me"> The URI that the communication endpoints should bind to </param> /// <returns> The URI at which the master communication was bound. </returns> //JAVA TO C# CONVERTER NOTE: Members cannot have the same name as their enclosing type: public virtual URI SwitchToMasterConflict(LifeSupport haCommunicationLife, URI me) { _userLog.info("I am %s, moving to master", MyId(_config)); // Do not wait for currently active transactions to complete before continuing switching. // - A master in a cluster is very important, without it the cluster cannot process any write requests // - Awaiting open transactions to complete assumes that this instance just now was a slave that is // switching to master, which means the previous master where these active transactions were hosted // is no longer available so these open transactions cannot continue and complete anyway, // so what's the point waiting for them? // - Read transactions may still be able to complete, but the correct response to failures in those // is to have them throw transient error exceptions hinting that they should be retried, // at which point they may get redirected to another instance, or to this instance if it has completed // the switch until then. _idGeneratorFactory.switchToMaster(); NeoStoreDataSource dataSource = _dataSourceSupplier.get(); dataSource.AfterModeSwitch(); Locks locks = dataSource.DependencyResolver.resolveDependency(typeof(Locks)); ConversationManager conversationManager = ConversationManagerFactory.apply(locks); Master master = MasterFactory.apply(conversationManager, haCommunicationLife); MasterServer masterServer = MasterServerFactory.apply(master, conversationManager); haCommunicationLife.Add(masterServer); _masterDelegateHandler.Delegate = master; haCommunicationLife.Start(); URI masterHaURI = GetMasterUri(me, masterServer, _config); _clusterMemberAvailability.memberIsAvailable(MASTER, masterHaURI, dataSource.StoreId); _userLog.info("I am %s, successfully moved to master", MyId(_config)); _slaveFactorySupplier.get().StoreId = dataSource.StoreId; return(masterHaURI); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldResolveMasterClientFactory() public virtual void ShouldResolveMasterClientFactory() { // Given LogEntryReader <ReadableClosablePositionAwareChannel> logEntryReader = new VersionAwareLogEntryReader <ReadableClosablePositionAwareChannel>(); MasterClientResolver resolver = new MasterClientResolver(NullLogProvider.Instance, Org.Neo4j.com.storecopy.ResponseUnpacker_Fields.NoOpResponseUnpacker, mock(typeof(InvalidEpochExceptionHandler)), 1, 1, 1, 1024, Suppliers.singleton(logEntryReader)); LifeSupport life = new LifeSupport(); try { life.Start(); MasterClient masterClient1 = resolver.Instantiate("cluster://localhost", 44, null, new Monitors(), StoreId.DEFAULT, life); assertThat(masterClient1, instanceOf(typeof(MasterClient320))); } finally { life.Shutdown(); } IllegalProtocolVersionException illegalProtocolVersionException = new IllegalProtocolVersionException(MasterClient214.PROTOCOL_VERSION.ApplicationProtocol, MasterClient310.PROTOCOL_VERSION.ApplicationProtocol, "Protocol is too modern"); // When resolver.Handle(illegalProtocolVersionException); // Then life = new LifeSupport(); try { life.Start(); MasterClient masterClient2 = resolver.Instantiate("cluster://localhost", 55, null, new Monitors(), StoreId.DEFAULT, life); assertThat(masterClient2, instanceOf(typeof(MasterClient214))); } finally { life.Shutdown(); } }
public ReplicationModule(RaftMachine raftMachine, MemberId myself, PlatformModule platformModule, Config config, Outbound <MemberId, Org.Neo4j.causalclustering.core.consensus.RaftMessages_RaftMessage> outbound, File clusterStateDirectory, FileSystemAbstraction fileSystem, LogProvider logProvider, AvailabilityGuard globalAvailabilityGuard, LocalDatabase localDatabase) { LifeSupport life = platformModule.Life; DurableStateStorage <GlobalSessionTrackerState> sessionTrackerStorage; sessionTrackerStorage = life.Add(new DurableStateStorage <>(fileSystem, clusterStateDirectory, SESSION_TRACKER_NAME, new GlobalSessionTrackerState.Marshal(new MemberId.Marshal()), config.Get(CausalClusteringSettings.global_session_tracker_state_size), logProvider)); _sessionTracker = new SessionTracker(sessionTrackerStorage); GlobalSession myGlobalSession = new GlobalSession(System.Guid.randomUUID(), myself); LocalSessionPool sessionPool = new LocalSessionPool(myGlobalSession); _progressTracker = new ProgressTrackerImpl(myGlobalSession); Duration initialBackoff = config.Get(CausalClusteringSettings.replication_retry_timeout_base); Duration upperBoundBackoff = config.Get(CausalClusteringSettings.replication_retry_timeout_limit); TimeoutStrategy progressRetryStrategy = new ExponentialBackoffStrategy(initialBackoff, upperBoundBackoff); long availabilityTimeoutMillis = config.Get(CausalClusteringSettings.replication_retry_timeout_base).toMillis(); _replicator = new RaftReplicator(raftMachine, myself, outbound, sessionPool, _progressTracker, progressRetryStrategy, availabilityTimeoutMillis, globalAvailabilityGuard, logProvider, localDatabase, platformModule.Monitors); }
private void ShouldGatherForensicsInFullBackupRequest(bool forensics) { // GIVEN Response <Void> response = Response.empty(); StoreId storeId = response.StoreId; string host = "localhost"; int port = PortAuthority.allocatePort(); LifeSupport life = new LifeSupport(); LogEntryReader <ReadableClosablePositionAwareChannel> reader = new VersionAwareLogEntryReader <ReadableClosablePositionAwareChannel>(); NullLogProvider logProvider = NullLogProvider.Instance; ResponseUnpacker responseUnpacker = mock(typeof(ResponseUnpacker)); ByteCounterMonitor byteCounterMonitor = mock(typeof(ByteCounterMonitor)); RequestMonitor requestMonitor = mock(typeof(RequestMonitor)); BackupClient client = new BackupClient(host, port, null, logProvider, storeId, 10_000, responseUnpacker, byteCounterMonitor, requestMonitor, reader); life.Add(client); ControlledBackupInterface backup = new ControlledBackupInterface(); HostnamePort hostnamePort = new HostnamePort(host, port); life.Add(new BackupServer(backup, hostnamePort, logProvider, byteCounterMonitor, requestMonitor)); life.Start(); try { // WHEN StoreWriter writer = mock(typeof(StoreWriter)); client.FullBackup(writer, forensics); // THEN assertEquals(forensics, backup.ReceivedForensics); } finally { life.Shutdown(); } }
private RaftLog CreateRaftLog(Config config, LifeSupport life, FileSystemAbstraction fileSystem, File clusterStateDirectory, ChannelMarshal <ReplicatedContent> marshal, LogProvider logProvider, JobScheduler scheduler) { EnterpriseCoreEditionModule.RaftLogImplementation raftLogImplementation = Enum.Parse(typeof(EnterpriseCoreEditionModule.RaftLogImplementation), config.Get(CausalClusteringSettings.raft_log_implementation)); switch (raftLogImplementation) { case EnterpriseCoreEditionModule.RaftLogImplementation.IN_MEMORY: { return(new InMemoryRaftLog()); } case EnterpriseCoreEditionModule.RaftLogImplementation.SEGMENTED: { long rotateAtSize = config.Get(CausalClusteringSettings.raft_log_rotation_size); int readerPoolSize = config.Get(CausalClusteringSettings.raft_log_reader_pool_size); CoreLogPruningStrategy pruningStrategy = (new CoreLogPruningStrategyFactory(config.Get(CausalClusteringSettings.raft_log_pruning_strategy), logProvider)).newInstance(); File directory = new File(clusterStateDirectory, RAFT_LOG_DIRECTORY_NAME); return(life.Add(new SegmentedRaftLog(fileSystem, directory, rotateAtSize, marshal, logProvider, readerPoolSize, systemClock(), scheduler, pruningStrategy))); } default: throw new System.InvalidOperationException("Unknown raft log implementation: " + raftLogImplementation); } }
public override Slave NewSlave(LifeSupport life, ClusterMember clusterMember, string originHostNameOrIp, int originPort) { //JAVA TO C# CONVERTER WARNING: The .NET Type.FullName property will not always yield results identical to the Java Class.getName method: return(life.Add(new SlaveClient(clusterMember.InstanceId, clusterMember.HAUri.Host, clusterMember.HAUri.Port, originHostNameOrIp, _logProvider, _storeId, 2, _chunkSize, _monitors.newMonitor(typeof(ByteCounterMonitor), typeof(SlaveClient).FullName), _monitors.newMonitor(typeof(RequestMonitor), typeof(SlaveClient).FullName), _entryReader.get()))); }
//JAVA TO C# CONVERTER WARNING: 'final' parameters are ignored unless the option to convert to C# 7.2 'in' parameters is selected: //ORIGINAL LINE: public ConsensusModule(org.neo4j.causalclustering.identity.MemberId myself, final org.neo4j.graphdb.factory.module.PlatformModule platformModule, org.neo4j.causalclustering.messaging.Outbound<org.neo4j.causalclustering.identity.MemberId,RaftMessages_RaftMessage> outbound, java.io.File clusterStateDirectory, org.neo4j.causalclustering.discovery.CoreTopologyService coreTopologyService) public ConsensusModule(MemberId myself, PlatformModule platformModule, Outbound <MemberId, RaftMessages_RaftMessage> outbound, File clusterStateDirectory, CoreTopologyService coreTopologyService) { //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final org.neo4j.kernel.configuration.Config config = platformModule.config; Config config = platformModule.Config; //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final org.neo4j.logging.internal.LogService logging = platformModule.logging; LogService logging = platformModule.Logging; //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final org.neo4j.io.fs.FileSystemAbstraction fileSystem = platformModule.fileSystem; FileSystemAbstraction fileSystem = platformModule.FileSystem; //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final org.neo4j.kernel.lifecycle.LifeSupport life = platformModule.life; LifeSupport life = platformModule.Life; LogProvider logProvider = logging.InternalLogProvider; //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final org.neo4j.causalclustering.core.state.storage.SafeChannelMarshal<org.neo4j.causalclustering.core.replication.ReplicatedContent> marshal = org.neo4j.causalclustering.messaging.marshalling.CoreReplicatedContentMarshal.marshaller(); SafeChannelMarshal <ReplicatedContent> marshal = CoreReplicatedContentMarshal.marshaller(); RaftLog underlyingLog = CreateRaftLog(config, life, fileSystem, clusterStateDirectory, marshal, logProvider, platformModule.JobScheduler); _raftLog = new MonitoredRaftLog(underlyingLog, platformModule.Monitors); StateStorage <TermState> termState; StateStorage <VoteState> voteState; StateStorage <RaftMembershipState> raftMembershipStorage; StateStorage <TermState> durableTermState = life.Add(new DurableStateStorage <TermState>(fileSystem, clusterStateDirectory, RAFT_TERM_NAME, new TermState.Marshal(), config.Get(CausalClusteringSettings.term_state_size), logProvider)); termState = new MonitoredTermStateStorage(durableTermState, platformModule.Monitors); voteState = life.Add(new DurableStateStorage <>(fileSystem, clusterStateDirectory, RAFT_VOTE_NAME, new VoteState.Marshal(new MemberId.Marshal()), config.Get(CausalClusteringSettings.vote_state_size), logProvider)); raftMembershipStorage = life.Add(new DurableStateStorage <>(fileSystem, clusterStateDirectory, RAFT_MEMBERSHIP_NAME, new RaftMembershipState.Marshal(), config.Get(CausalClusteringSettings.raft_membership_state_size), logProvider)); TimerService timerService = new TimerService(platformModule.JobScheduler, logProvider); _leaderAvailabilityTimers = CreateElectionTiming(config, timerService, logProvider); int?minimumConsensusGroupSize = config.Get(CausalClusteringSettings.minimum_core_cluster_size_at_runtime); MemberIdSetBuilder memberSetBuilder = new MemberIdSetBuilder(); SendToMyself leaderOnlyReplicator = new SendToMyself(myself, outbound); _raftMembershipManager = new RaftMembershipManager(leaderOnlyReplicator, memberSetBuilder, _raftLog, logProvider, minimumConsensusGroupSize.Value, _leaderAvailabilityTimers.ElectionTimeout, systemClock(), config.Get(join_catch_up_timeout).toMillis(), raftMembershipStorage); platformModule.Dependencies.satisfyDependency(_raftMembershipManager); life.Add(_raftMembershipManager); _inFlightCache = InFlightCacheFactory.create(config, platformModule.Monitors); RaftLogShippingManager logShipping = new RaftLogShippingManager(outbound, logProvider, _raftLog, timerService, systemClock(), myself, _raftMembershipManager, _leaderAvailabilityTimers.ElectionTimeout, config.Get(catchup_batch_size), config.Get(log_shipping_max_lag), _inFlightCache); bool supportsPreVoting = config.Get(CausalClusteringSettings.enable_pre_voting); _raftMachine = new RaftMachine(myself, termState, voteState, _raftLog, _leaderAvailabilityTimers, outbound, logProvider, _raftMembershipManager, logShipping, _inFlightCache, config.Get(refuse_to_be_leader), supportsPreVoting, platformModule.Monitors); DurationSinceLastMessageMonitor durationSinceLastMessageMonitor = new DurationSinceLastMessageMonitor(); platformModule.Monitors.addMonitorListener(durationSinceLastMessageMonitor); platformModule.Dependencies.satisfyDependency(durationSinceLastMessageMonitor); string dbName = config.Get(CausalClusteringSettings.database); life.Add(new RaftCoreTopologyConnector(coreTopologyService, _raftMachine, dbName)); life.Add(logShipping); }
private KernelData CreateKernelData(FileSystemAbstraction fileSystem, PageCache pageCache, File storeDir, Config config, LifeSupport life, DataSourceManager dataSourceManager) { return(life.Add(new KernelData(fileSystem, pageCache, storeDir, config, dataSourceManager))); }