Exemplo n.º 1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void moveSingleFiles() throws java.io.IOException
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void MoveSingleFiles()
        {
            // given
            File sharedParent = TestDirectory.cleanDirectory("shared_parent");
            File sourceParent = new File(sharedParent, "source");

            assertTrue(sourceParent.mkdirs());
            File sourceFile = new File(sourceParent, "file.txt");

            assertTrue(sourceFile.createNewFile());
            WriteToFile(sourceFile, "Garbage data");
            File targetParent = new File(sharedParent, "target");

            assertTrue(targetParent.mkdirs());
            File targetFile = new File(targetParent, "file.txt");

            // when
            _subject.traverseForMoving(sourceFile).forEach(MoveToDirectory(targetParent));

            // then
            assertEquals("Garbage data", ReadFromFile(targetFile));
        }
Exemplo n.º 2
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private void testFailoverWithAdditionalSlave(int clusterSize, int[] slaveIndexes) throws Throwable
		 private void TestFailoverWithAdditionalSlave( int clusterSize, int[] slaveIndexes )
		 {
			  File root = Dir.cleanDirectory( "testcluster_" + Name.MethodName );
			  ClusterManager manager = ( new ClusterManager.Builder() ).withRootDirectory(root).withCluster(ClusterManager.clusterOfSize(clusterSize)).build();

			  try
			  {
					manager.Start();
					ClusterManager.ManagedCluster cluster = manager.Cluster;

					cluster.Await( allSeesAllAsAvailable() );
					cluster.Await( masterAvailable() );

					ICollection<HighlyAvailableGraphDatabase> failed = new List<HighlyAvailableGraphDatabase>();
					ICollection<ClusterManager.RepairKit> repairKits = new List<ClusterManager.RepairKit>();

					foreach ( int slaveIndex in slaveIndexes )
					{
						 HighlyAvailableGraphDatabase nthSlave = GetNthSlave( cluster, slaveIndex );
						 failed.Add( nthSlave );
						 ClusterManager.RepairKit repairKit = cluster.Fail( nthSlave );
						 repairKits.Add( repairKit );
					}

					HighlyAvailableGraphDatabase oldMaster = cluster.Master;
					failed.Add( oldMaster );
					repairKits.Add( cluster.Fail( oldMaster ) );

					cluster.Await( masterAvailable( ToArray( failed ) ) );

					foreach ( ClusterManager.RepairKit repairKit in repairKits )
					{
						 repairKit.Repair();
					}

					Thread.Sleep( 3000 ); // give repaired instances a chance to cleanly rejoin and exit faster
			  }
			  finally
			  {
					manager.SafeShutdown();
			  }
		 }
Exemplo n.º 3
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: public java.io.File cleanDirectory(String name) throws java.io.IOException
        public virtual File CleanDirectory(string name)
        {
            return(_testDirectory.cleanDirectory(name));
        }
Exemplo n.º 4
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private void testFailOver(int clusterSize) throws Throwable
        private void TestFailOver(int clusterSize)
        {
            // given
            ClusterManager clusterManager = (new ClusterManager.Builder()).withRootDirectory(Dir.cleanDirectory("failover")).withCluster(ClusterManager.clusterOfSize(clusterSize)).build();

            clusterManager.Start();
            ClusterManager.ManagedCluster cluster = clusterManager.Cluster;

            cluster.Await(ClusterManager.allSeesAllAsAvailable());
            HighlyAvailableGraphDatabase oldMaster = cluster.Master;

            // When
            long start = System.nanoTime();

            ClusterManager.RepairKit repairKit = cluster.Fail(oldMaster);
            Logger.Logger.warning("Shut down master");

            // Then
            cluster.Await(ClusterManager.masterAvailable(oldMaster));
            long end = System.nanoTime();

            Logger.Logger.warning("Failover took:" + (end - start) / 1000000 + "ms");

            repairKit.Repair();
            Thread.Sleep(3000);                 // give repaired instance chance to cleanly rejoin and exit faster

            clusterManager.SafeShutdown();
        }
Exemplo n.º 5
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Before public void before() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void Before()
        {
            _storeDir  = Dir.databaseDir();
            _backupDir = Dir.cleanDirectory("full-backup").AbsolutePath;
        }