//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldTerminateOnStop() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldTerminateOnStop() { // given: this task is gonna take >20 ms total Semaphore semaphore = new Semaphore(-20); ThreadStart task = () => { LockSupport.parkNanos(1_000_000); // 1 ms semaphore.release(); }; ContinuousJob continuousJob = new ContinuousJob(_scheduler.threadFactory(Group.RAFT_BATCH_HANDLER), task, NullLogProvider.Instance); // when long startTime = DateTimeHelper.CurrentUnixTimeMillis(); using (Lifespan ignored = new Lifespan(_scheduler, continuousJob)) { semaphore.acquireUninterruptibly(); } long runningTime = DateTimeHelper.CurrentUnixTimeMillis() - startTime; // then assertThat(runningTime, lessThan(DEFAULT_TIMEOUT_MS)); //noinspection StatementWithEmptyBody while (semaphore.tryAcquire()) { // consume all outstanding permits } // no more permits should be granted semaphore.tryAcquire(10, MILLISECONDS); }
private bool RealUsersExist(Config config) { bool result = false; File authFile = CommunitySecurityModule.getUserRepositoryFile(config); if (_outsideWorld.fileSystem().fileExists(authFile)) { result = true; // Check if it only contains the default neo4j user FileUserRepository userRepository = new FileUserRepository(_outsideWorld.fileSystem(), authFile, NullLogProvider.Instance); try { using (Lifespan life = new Lifespan(userRepository)) { ListSnapshot <User> users = userRepository.PersistedSnapshot; if (users.Values().Count == 1) { User user = users.Values()[0]; if (INITIAL_USER_NAME.Equals(user.Name()) && user.Credentials().matchesPassword(INITIAL_PASSWORD)) { // We allow overwriting an unmodified default neo4j user result = false; } } } } catch (IOException) { // Do not allow overwriting if we had a problem reading the file } } return(result); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldCreateEmptyCountsTrackerStoreWhenCreatingDatabase() public virtual void ShouldCreateEmptyCountsTrackerStoreWhenCreatingDatabase() { // GIVEN GraphDatabaseAPI db = ( GraphDatabaseAPI )_dbBuilder.newGraphDatabase(); // WHEN Db.shutdown(); // THEN assertTrue(_fs.fileExists(AlphaStoreFile())); assertFalse(_fs.fileExists(BetaStoreFile())); using (Lifespan life = new Lifespan()) { CountsTracker store = life.Add(CreateCountsTracker(_pageCache)); assertEquals(BASE_TX_ID, store.TxId()); assertEquals(INITIAL_MINOR_VERSION, store.MinorVersion()); assertEquals(0, store.TotalEntriesStored()); assertEquals(0, AllRecords(store).Count); } using (Lifespan life = new Lifespan()) { CountsTracker store = life.Add(CreateCountsTracker(_pageCache)); assertEquals(BASE_TX_ID, store.TxId()); assertEquals(INITIAL_MINOR_VERSION, store.MinorVersion()); assertEquals(0, store.TotalEntriesStored()); assertEquals(0, AllRecords(store).Count); } }
/// <summary> /// Creates a new HingeJoint Instance. /// </summary> /// <param name="body1">One of the bodies to be Jointed.</param> /// <param name="body2">One of the bodies to be Jointed.</param> /// <param name="anchor">The location of the Hinge.</param> /// <param name="lifeTime">A object Describing how long the object will be in the engine.</param> public HingeJoint(Body body1, Body body2, Vector2D anchor, Lifespan lifetime) : base(lifetime) { if (body1 == null) { throw new ArgumentNullException("body1"); } if (body2 == null) { throw new ArgumentNullException("body2"); } if (body1 == body2) { throw new ArgumentException("You cannot add a joint to a body to itself"); } this.body1 = body1; this.body2 = body2; body1.ApplyPosition(); body2.ApplyPosition(); Vector2D.Transform(ref body1.Matrices.ToBody, ref anchor, out this.localAnchor1); Vector2D.Transform(ref body2.Matrices.ToBody, ref anchor, out this.localAnchor2); this.softness = 0.001f; this.biasFactor = 0.2f; this.distanceTolerance = Scalar.PositiveInfinity; }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldUnMapThePrestateFileWhenTimingOutOnRotationAndAllowForShutdownInTheFailedRotationState() throws Throwable //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldUnMapThePrestateFileWhenTimingOutOnRotationAndAllowForShutdownInTheFailedRotationState() { // Given _dbBuilder.newGraphDatabase().shutdown(); CountsTracker store = CreateCountsTracker(_pageCache, Config.defaults(GraphDatabaseSettings.counts_store_rotation_timeout, "100ms")); using (Lifespan lifespan = new Lifespan(store)) { using (Org.Neo4j.Kernel.Impl.Api.CountsAccessor_Updater updater = store.Apply(2).get()) { updater.IncrementNodeCount(0, 1); } try { // when store.Rotate(3); fail("should have thrown"); } catch (RotationTimeoutException) { // good } } // and also no exceptions closing the page cache _pageCache.close(); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldRotateCountsStoreWhenClosingTheDatabase() public virtual void ShouldRotateCountsStoreWhenClosingTheDatabase() { // GIVEN GraphDatabaseAPI db = ( GraphDatabaseAPI )_dbBuilder.newGraphDatabase(); using (Transaction tx = Db.beginTx()) { Db.createNode(_a); tx.Success(); } // WHEN Db.shutdown(); // THEN assertTrue(_fs.fileExists(AlphaStoreFile())); assertTrue(_fs.fileExists(BetaStoreFile())); using (Lifespan life = new Lifespan()) { CountsTracker store = life.Add(CreateCountsTracker(_pageCache)); // a transaction for creating the label and a transaction for the node assertEquals(BASE_TX_ID + 1 + 1, store.TxId()); assertEquals(INITIAL_MINOR_VERSION, store.MinorVersion()); // one for all nodes and one for the created "A" label assertEquals(1 + 1, store.TotalEntriesStored()); assertEquals(1 + 1, AllRecords(store).Count); } }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: private void appendNullTransactionLogEntryToSetRaftIndexToMinusOne() throws java.io.IOException private void AppendNullTransactionLogEntryToSetRaftIndexToMinusOne() { ReadOnlyTransactionIdStore readOnlyTransactionIdStore = new ReadOnlyTransactionIdStore(_pageCache, _databaseLayout); LogFiles logFiles = LogFilesBuilder.activeFilesBuilder(_databaseLayout, _fs, _pageCache).withConfig(_config).withLastCommittedTransactionIdSupplier(() => readOnlyTransactionIdStore.LastClosedTransactionId - 1).build(); long dummyTransactionId; using (Lifespan lifespan = new Lifespan(logFiles)) { FlushableChannel channel = logFiles.LogFile.Writer; TransactionLogWriter writer = new TransactionLogWriter(new LogEntryWriter(channel)); long lastCommittedTransactionId = readOnlyTransactionIdStore.LastCommittedTransactionId; PhysicalTransactionRepresentation tx = new PhysicalTransactionRepresentation(Collections.emptyList()); sbyte[] txHeaderBytes = LogIndexTxHeaderEncoding.encodeLogIndexAsTxHeader(-1); tx.SetHeader(txHeaderBytes, -1, -1, -1, lastCommittedTransactionId, -1, -1); dummyTransactionId = lastCommittedTransactionId + 1; writer.Append(tx, dummyTransactionId); channel.PrepareForFlush().flush(); } File neoStoreFile = _databaseLayout.metadataStore(); MetaDataStore.setRecord(_pageCache, neoStoreFile, LAST_TRANSACTION_ID, dummyTransactionId); }
private void CreateWalls() { var wallCoff = new Coefficients(0.8f, 0.95f); var wallLife = new Lifespan(); var flrState = new PhysicsState(new ALVector2D((float)0.0, ((float)ActualWidth) * ((float)0.5), (float)ActualHeight + 100.0)); var flrShape = new PolygonShape(VertexHelper.CreateRectangle(ActualWidth, 200), 2); var bdyFloor = new Body(flrState, flrShape, float.PositiveInfinity, wallCoff, wallLife); var ceiState = new PhysicsState(new ALVector2D((float)0.0, ((float)ActualWidth) * ((float)0.5), -100.0)); var ceiShape = new PolygonShape(VertexHelper.CreateRectangle(ActualWidth, 200), 2); var bdyCeiling = new Body(ceiState, ceiShape, float.PositiveInfinity, wallCoff, wallLife); var lwlState = new PhysicsState(new ALVector2D((float)0.0, -100.0, ((float)ActualHeight) * ((float)0.5))); var lwlShape = new PolygonShape(VertexHelper.CreateRectangle(200, ActualHeight), 2); var bdyLeftWall = new Body(lwlState, lwlShape, float.PositiveInfinity, wallCoff, wallLife); var rwlState = new PhysicsState(new ALVector2D((float)0.0, (float)ActualWidth + 100.0, ((float)ActualHeight) * ((float)0.5))); var rwlShape = new PolygonShape(VertexHelper.CreateRectangle(200, ActualHeight), 2); var bdyRightWall = new Body(rwlState, rwlShape, float.PositiveInfinity, wallCoff, wallLife); engine.AddBody(bdyFloor); engine.AddBody(bdyCeiling); engine.AddBody(bdyLeftWall); engine.AddBody(bdyRightWall); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldRotateCountsStoreWhenRotatingLog() throws java.io.IOException //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldRotateCountsStoreWhenRotatingLog() { // GIVEN GraphDatabaseAPI db = ( GraphDatabaseAPI )_dbBuilder.newGraphDatabase(); // WHEN doing a transaction (actually two, the label-mini-tx also counts) using (Transaction tx = Db.beginTx()) { Db.createNode(_b); tx.Success(); } // and rotating the log (which implies flushing) CheckPoint(db); // and creating another node after it using (Transaction tx = Db.beginTx()) { Db.createNode(_c); tx.Success(); } // THEN assertTrue(_fs.fileExists(AlphaStoreFile())); assertTrue(_fs.fileExists(BetaStoreFile())); //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final org.neo4j.io.pagecache.PageCache pageCache = db.getDependencyResolver().resolveDependency(org.neo4j.io.pagecache.PageCache.class); PageCache pageCache = Db.DependencyResolver.resolveDependency(typeof(PageCache)); using (Lifespan life = new Lifespan()) { CountsTracker store = life.Add(CreateCountsTracker(pageCache)); // NOTE since the rotation happens before the second transaction is committed we do not see those changes // in the stats // a transaction for creating the label and a transaction for the node assertEquals(BASE_TX_ID + 1 + 1, store.TxId()); assertEquals(INITIAL_MINOR_VERSION, store.MinorVersion()); // one for all nodes and one for the created "B" label assertEquals(1 + 1, store.TotalEntriesStored()); assertEquals(1 + 1, AllRecords(store).Count); } // on the other hand the tracker should read the correct value by merging data on disk and data in memory //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final CountsTracker tracker = db.getDependencyResolver().resolveDependency(org.neo4j.kernel.impl.storageengine.impl.recordstorage.RecordStorageEngine.class).testAccessNeoStores().getCounts(); CountsTracker tracker = Db.DependencyResolver.resolveDependency(typeof(RecordStorageEngine)).testAccessNeoStores().Counts; assertEquals(1 + 1, tracker.NodeCount(-1, newDoubleLongRegister()).readSecond()); int labelId; using (Transaction tx = Db.beginTx()) { KernelTransaction transaction = Db.DependencyResolver.resolveDependency(typeof(ThreadToStatementContextBridge)).getKernelTransactionBoundToThisThread(true); labelId = transaction.TokenRead().nodeLabel(_c.name()); } assertEquals(1, tracker.NodeCount(labelId, newDoubleLongRegister()).readSecond()); Db.shutdown(); }
internal void ConfigureLifespan(uint duration) { Lifespan = new Lifespan { CreationTime = DateTime.UtcNow, Duration = duration }; }
public VelocityLimitLogic(Scalar maxLinearVelocity, Scalar maxAngularVelocity, Lifespan lifetime) : base(lifetime) { if (maxLinearVelocity < 0) { throw new ArgumentOutOfRangeException("maxLinearVelocity"); } if (maxAngularVelocity < 0) { throw new ArgumentOutOfRangeException("maxAngularVelocity"); } this.maxLinearVelocity = maxLinearVelocity; this.maxAngularVelocity = maxAngularVelocity; }
internal void ConfigureLifespan(uint defaultDuration) { Lifespan = new Lifespan { CreationTime = DateTime.UtcNow, Duration = _timeout.HasValue ? (uint)_timeout.Value.TotalSeconds : defaultDuration }; }
public StoreFileInfo(Guid id, string path, long size, DateTime created, Lifespan? lifespan) { Id = id; Path = path; Size = size; Created = created; Lifespan = lifespan; }
protected PhysicsLogic(Lifespan lifetime) { if (lifetime == null) { throw new ArgumentNullException("lifetime"); } this.lifetime = lifetime; }
public Pendable(Lifespan lifetime) { if (lifetime == null) { throw new ArgumentNullException("lifetime"); } this.lifetime = lifetime; }
protected Joint(Lifespan lifetime) { if (lifetime == null) { throw new ArgumentNullException("lifetime"); } this.lifetime = lifetime; }
private void CreateDurableState <T>(string name, StateMarshal <T> marshal) { DurableStateStorage <T> storage = new DurableStateStorage <T>(Fsa.get(), _clusterStateDirectory.get(), name, marshal, 1024, NullLogProvider.Instance); //noinspection EmptyTryBlock: Will create initial state. using (Lifespan ignored = new Lifespan(storage)) { } }
public FixedAngleJoint(Body body, Lifespan lifetime) : base(lifetime) { if (body == null) { throw new ArgumentNullException("body"); } this.body = body; this.angle = body.State.Position.Angular; this.softness = 0.001f; this.biasFactor = 0.2f; }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: private static void appendCheckpoint(org.neo4j.kernel.impl.transaction.log.files.LogFiles logFiles, org.neo4j.kernel.recovery.LogTailScanner tailScanner) throws java.io.IOException private static void AppendCheckpoint(LogFiles logFiles, LogTailScanner tailScanner) { using (Lifespan lifespan = new Lifespan(logFiles)) { FlushablePositionAwareChannel writer = logFiles.LogFile.Writer; TransactionLogWriter transactionLogWriter = new TransactionLogWriter(new LogEntryWriter(writer)); transactionLogWriter.CheckPoint(tailScanner.TailInformation.lastCheckPoint.LogPosition); writer.PrepareForFlush().flush(); } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldBeAbleToReadUpToDateValueWhileAnotherThreadIsPerformingRotation() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldBeAbleToReadUpToDateValueWhileAnotherThreadIsPerformingRotation() { // given CountsOracle oracle = SomeData(); const int firstTransaction = 2; int secondTransaction = 3; using (Lifespan life = new Lifespan()) { CountsTracker tracker = life.Add(NewTracker()); oracle.Update(tracker, firstTransaction); tracker.Rotate(firstTransaction); } // when //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final org.neo4j.kernel.impl.store.CountsOracle delta = new org.neo4j.kernel.impl.store.CountsOracle(); CountsOracle delta = new CountsOracle(); { CountsOracle.Node n1 = delta.Node(1); CountsOracle.Node n2 = delta.Node(1, 4); // Label 4 has not been used before... delta.Relationship(n1, 1, n2); delta.Relationship(n2, 2, n1); // relationshipType 2 has not been used before... } delta.Update(oracle); using (Lifespan life = new Lifespan()) { //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final org.neo4j.test.Barrier_Control barrier = new org.neo4j.test.Barrier_Control(); Org.Neo4j.Test.Barrier_Control barrier = new Org.Neo4j.Test.Barrier_Control(); CountsTracker tracker = life.Add(new CountsTrackerAnonymousInnerClass(this, ResourceManager.logProvider(), ResourceManager.fileSystem(), ResourceManager.pageCache(), Config.defaults(), EmptyVersionContextSupplier.EMPTY, barrier)); Future <Void> task = Threading.execute(t => { try { delta.Update(t, secondTransaction); t.rotate(secondTransaction); } catch (IOException e) { throw new AssertionError(e); } return(null); }, tracker); // then barrier.Await(); oracle.Verify(tracker); barrier.Release(); task.get(); oracle.Verify(tracker); } }
public void TestTimePassing() { Lifespan ls = new Lifespan(1); TimeSpan ts = new TimeSpan(0, 0, 0, 0, 500); GameTime gt = new GameTime(ts, ts); ls.Update(gt); Assert.AreEqual(.5, ls.Halflife); ls.Update(gt); Assert.AreEqual(1, ls.Halflife); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldPickTheUncorruptedStoreWhenTruncatingAfterTheHeader() throws java.io.IOException //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldPickTheUncorruptedStoreWhenTruncatingAfterTheHeader() { /* * The problem was that if we were successful in writing the header but failing immediately after, we would * read 0 as counter for entry data and pick the corrupted store thinking that it was simply empty. */ Store store = CreateTestStore(); Pair <File, KeyValueStoreFile> file = store.RotationStrategy.create(EMPTY_DATA_PROVIDER, 1); Pair <File, KeyValueStoreFile> next = store.RotationStrategy.next(file.First(), Headers.HeadersBuilder().put(TX_ID, (long)42).headers(), Data((Entry)(key, value) => { key.putByte(0, ( sbyte )'f'); key.putByte(1, ( sbyte )'o'); key.putByte(2, ( sbyte )'o'); value.putInt(0, 42); })); file.Other().Dispose(); File correct = next.First(); Pair <File, KeyValueStoreFile> nextNext = store.RotationStrategy.next(correct, Headers.HeadersBuilder().put(TX_ID, (long)43).headers(), Data((key, value) => { key.putByte(0, ( sbyte )'f'); key.putByte(1, ( sbyte )'o'); key.putByte(2, ( sbyte )'o'); value.putInt(0, 42); }, (key, value) => { key.putByte(0, ( sbyte )'b'); key.putByte(1, ( sbyte )'a'); key.putByte(2, ( sbyte )'r'); value.putInt(0, 4242); })); next.Other().Dispose(); File corrupted = nextNext.First(); nextNext.Other().Dispose(); using (StoreChannel channel = _resourceManager.fileSystem().open(corrupted, OpenMode.READ_WRITE)) { channel.Truncate(16 * 4); } // then using (Lifespan life = new Lifespan()) { life.Add(store); assertNotNull(store.Get("foo")); assertEquals(42L, store.Headers().get(TX_ID).longValue()); } }
public void When_Duration_Exceeded_Timeout_Returns_True() { var lifespan = new Lifespan { CreationTime = DateTime.UtcNow, Duration = 250 }; Thread.Sleep(500); Assert.IsTrue(lifespan.TimedOut()); }
public void When_Duration_NotExceeded_Timeout_Returns_False() { var lifespan = new Lifespan { CreationTime = DateTime.UtcNow, Duration = 500 }; Thread.Sleep(250); Assert.IsFalse(lifespan.TimedOut()); }
public FixedHingeJoint(Body body, Vector2D anchor, Lifespan lifetime) : base(lifetime) { if (body == null) { throw new ArgumentNullException("body"); } this.body = body; this.anchor = anchor; body.ApplyPosition(); Vector2D.Transform(ref body.Matrices.ToBody, ref anchor, out this.localAnchor1); this.softness = 0.001f; this.biasFactor = 0.2f; this.distanceTolerance = Scalar.PositiveInfinity; }
/// <summary> /// Creates a new MoveToPointLogic object. /// </summary> /// <param name="body">The Body this logic will act on.</param> /// <param name="destination">The Point it will move the Body too.</param> /// <param name="maxAcceleration">The maximum acceleration to be applied to the Body</param> /// <param name="maxVelocity">The maximum velocity this logic will accelerate the Body too.</param> /// <param name="isStationKeeping">states if the logic will maintian the bodies location even after it reaches its destination.</param> /// <param name="lifetime">the LifeTime of the object. The object will be removed from the engine when it is Expired.</param> public MoveToPointLogic(Body body, Vector2D destination, Scalar maxAcceleration, Scalar maxVelocity, bool isStationKeeping, Lifespan lifetime) : base(lifetime) { if (maxAcceleration <= 0) { throw new ArgumentOutOfRangeException("maxAcceleration", "maxAcceleration must be greater then zero"); } if (maxVelocity <= 0) { throw new ArgumentOutOfRangeException("maxVelocity", "maxVelocity must be greater then zero"); } if (body == null) { throw new ArgumentNullException("body"); } this.maxAcceleration = maxAcceleration; this.maxVelocity = maxVelocity; this.destination = destination; this.body = body; this.IsStationKeeping = isStationKeeping; }
/// <summary> /// Initializes a new instance of the Event class. /// </summary> /// <param name="eventId"> /// The event ID. /// </param> /// <param name="eventType"> /// The event type. /// </param> /// <param name="lifespan"> /// The maximum duration of the event. /// </param> /// <param name="dispatchTime"> /// The time to dispatch the event (or DISPATCH_IMMEDIATELY). /// </param> /// <param name="senderId"> /// The sender ID (or SENDER_ID_IRRELEVANT). /// </param> /// <param name="receiverId"> /// The receiver ID (or RECEIVER_ID_IRRELEVANT). /// </param> /// <param name="eventDelegate"> /// The delegate to call when the event is triggered. /// </param> /// <param name="eventData"> /// The event data. /// </param> private Event( int eventId, EventType eventType, Lifespan lifespan, double dispatchTime, int senderId, int receiverId, EventDelegate <T> eventDelegate, T eventData) : base(eventId, eventType, lifespan, dispatchTime, senderId, receiverId, eventDelegate, typeof(T), eventData) { }
public AngleJoint(Body body1, Body body2, Lifespan lifetime) : base(lifetime) { if (body1 == null) { throw new ArgumentNullException("body1"); } if (body2 == null) { throw new ArgumentNullException("body2"); } if (body1 == body2) { throw new ArgumentException("You cannot add a joint to a body to itself"); } this.body1 = body1; this.body2 = body2; this.angle = MathHelper.ClampAngle(body1.State.Position.Angular - body2.State.Position.Angular); this.softness = 0.001f; this.biasFactor = 0.2f; }
public GlobalFluidLogic( Scalar dragCoefficient, Scalar density, Vector2D fluidVelocity, Lifespan lifetime) : base(lifetime) { this.dragCoefficient = dragCoefficient; this.density = density; this.fluidVelocity = fluidVelocity; this.items = new List <Wrapper>(); this.Order = 1; }
public void When_Duration_Exceeded_Timeout_Returns_True_Multiple_Tries() { var lifespan = new Lifespan { CreationTime = DateTime.UtcNow, Duration = 500 }; Thread.Sleep(100); Assert.IsFalse(lifespan.TimedOut()); Thread.Sleep(600); Assert.IsTrue(lifespan.TimedOut()); }
public Viewport(Rectangle rectangle, Matrix2x3 projection, Scene scene, Lifespan lifetime) : base(lifetime) { this.syncRoot = new object(); this.matrixArray = new Scalar[16]; this.rectangle = rectangle; this.scene = scene; this.toScreen = projection; Calc(); this.scene.AddViewport(this); AddClipper(); }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: private void addRandomBytesToLastLogFile(System.Func<sbyte> byteSource) throws java.io.IOException private void AddRandomBytesToLastLogFile(System.Func <sbyte> byteSource) { using (Lifespan lifespan = new Lifespan()) { LogFile transactionLogFile = _logFiles.LogFile; lifespan.Add(_logFiles); FlushablePositionAwareChannel logFileWriter = transactionLogFile.Writer; for (int i = 0; i < 10; i++) { logFileWriter.Put(byteSource()); } } }
/// <summary> /// Creates a new GravityPointMass Instance. /// </summary> /// <param name="body">The body that will be the source of gravity.</param> /// <param name="metersPerDistanceUnit">The scale of of the universe.</param> /// <param name="lifetime">A object Describing how long the object will be in the engine.</param> public GravityPointMass(Body body, Scalar metersPerDistanceUnit, Lifespan lifetime) : base(lifetime) { if (body == null) { throw new ArgumentNullException("body"); } if (metersPerDistanceUnit <= 0) { throw new ArgumentOutOfRangeException("metersPerDistanceUnit"); } this.body = body; this.metersPerDistanceUnit = metersPerDistanceUnit; }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldRunJobContinuously() throws Throwable //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldRunJobContinuously() { // given System.Threading.CountdownEvent latch = new System.Threading.CountdownEvent(10); ThreadStart task = latch.countDown; ContinuousJob continuousJob = new ContinuousJob(_scheduler.threadFactory(Group.RAFT_BATCH_HANDLER), task, NullLogProvider.Instance); // when using (Lifespan ignored = new Lifespan(_scheduler, continuousJob)) { //then assertTrue(latch.await(DEFAULT_TIMEOUT_MS, MILLISECONDS)); } }
/// <summary> /// Creates a new instance of the ExplosionLogic /// </summary> /// <param name="location">ground zero</param> /// <param name="velocity">the velocity of the explosion (this would be from the missile or bomb that spawns it).</param> /// <param name="pressurePulseSpeed">the speed at which the explosion expands</param> /// <param name="dragCoefficient">the drag Coefficient</param> /// <param name="mass">the mass of the expanding cloud</param> /// <param name="lifetime"></param> public ExplosionLogic( Vector2D location, Vector2D velocity, Scalar pressurePulseSpeed, Scalar dragCoefficient, Scalar mass, Lifespan lifetime) : base(lifetime) { this.dragCoefficient = dragCoefficient; this.pressurePulseSpeed = pressurePulseSpeed; this.explosionBody = new Body( new PhysicsState(new ALVector2D(0, location), new ALVector2D(0, velocity)), new CircleShape(1, 3), mass, new Coefficients(1, 1), lifetime); this.explosionBody.IgnoresCollisionResponse = true; this.explosionBody.Collided += OnCollided; this.items = new List<Wrapper>(); }
public static string GetDescription(Lifespan lifespan) { foreach (var fieldInfo in typeof(Lifespans).GetFields()) { if ((Lifespan)fieldInfo.GetValue(null) != lifespan) { continue; } DescriptionAttribute[] attributes = (DescriptionAttribute[])fieldInfo.GetCustomAttributes( typeof(DescriptionAttribute), false); if (attributes.Length > 0) { return attributes[0].Description; } } return lifespan.ToString(); }
public void EnsureDirectoryExists(string rootPath, Lifespan lifespan) { var path = Path.GetDirectoryName(GetFullPath(rootPath, lifespan)); if (!Directory.Exists(path)) Directory.CreateDirectory(path); }
public bool Exists(string rootPath, Lifespan lifespan) { return File.Exists(GetFullPath(rootPath, lifespan)); }
public string GetFullPath(string rootPath, Lifespan lifespan) { return Path.Combine(rootPath, lifespan == Lifespan.Permanent ? _relativePermanentPath : _relativeTransientPath); }
public Guid Import(string path, Lifespan lifespan) { try { var file = StoreFile.Create(); file.ReplaceWith(_rootPath, path, lifespan); return file.Id; } catch (Exception e) { throw new StoreFileImportException(path, e); } }
/// <summary> /// Initializes a new instance of the Event class. /// </summary> /// <param name="eventId"> /// The event ID. /// </param> /// <param name="eventType"> /// The event type. /// </param> /// <param name="lifespan"> /// The maximum duration of the event. /// </param> /// <param name="dispatchTime"> /// The time to dispatch the event (or DISPATCH_IMMEDIATELY). /// </param> /// <param name="senderId"> /// The sender ID (or SENDER_ID_IRRELEVANT). /// </param> /// <param name="receiverId"> /// The receiver ID (or RECEIVER_ID_IRRELEVANT). /// </param> /// <param name="eventDelegate"> /// The delegate to call when the event is triggered. /// </param> /// <param name="eventDataType"> /// The type of event data. /// </param> /// <param name="eventData"> /// The event data. /// </param> protected Event( int eventId, EventType eventType, Lifespan lifespan, double dispatchTime, int senderId, int receiverId, System.Delegate eventDelegate, System.Type eventDataType, object eventData) { EventId = eventId; EventType = eventType; EventLifespan = lifespan; DispatchTime = dispatchTime; SenderId = senderId; ReceiverId = receiverId; EventDelegate = eventDelegate; EventDataType = eventDataType; EventData = eventData; }
public Guid Save(string data, Lifespan lifespan) { return Save(new MemoryStream(Encoding.ASCII.GetBytes(data)), lifespan); }
public void Overwrite(string rootPath, Stream data, Lifespan lifespan) { var path = GetFullPath(rootPath, lifespan); if (File.Exists(path)) File.Delete(path); else EnsureDirectoryExists(rootPath, lifespan); data.Save(path); }
public void ReplaceWith(string rootPath, string path, Lifespan lifespan) { Delete(rootPath); EnsureDirectoryExists(rootPath, lifespan); File.Move(path, GetFullPath(rootPath, lifespan)); }
public void SetLifespan(Guid id, Lifespan lifespan) { try { StoreFile.FromGuid(id).SetLifespan(_rootPath, lifespan); } catch (Exception e) { throw new StoreFileLifespanException(id, e); } }
public StoreFileInfo Create(Lifespan lifespan) { var file = StoreFile.Create(); file.EnsureDirectoryExists(_rootPath, lifespan); return new StoreFileInfo(file.Id, file.GetFullPath(_rootPath, lifespan), 0, DateTime.MinValue, lifespan); }
public void SetLifespan(string rootPath, Lifespan lifespan) { EnsureDirectoryExists(rootPath, lifespan); if (lifespan == Lifespan.Transient && Exists(rootPath, Lifespan.Permanent) && !Exists(rootPath, Lifespan.Transient)) File.Move(GetFullPath(rootPath, Lifespan.Permanent), GetFullPath(rootPath, Lifespan.Transient)); else if (lifespan == Lifespan.Permanent && Exists(rootPath, Lifespan.Transient) && !Exists(rootPath, Lifespan.Permanent)) File.Move(GetFullPath(rootPath, Lifespan.Transient), GetFullPath(rootPath, Lifespan.Permanent)); }
public Guid Save(Stream data, Lifespan lifespan) { var file = StoreFile.Create(); try { StoreFile.FromGuid(file.Id).Overwrite(_rootPath, data, lifespan); return file.Id; } catch (Exception e) { throw new StoreFileSaveException(file.Id, e); } }
/// <summary> /// Creates a new GravityPointField Instance. /// </summary> /// <param name="location">The location of the Gravity point.</param> /// <param name="gravity"></param> /// <param name="lifetime"></param> public GravityPointField(Vector2D location, Scalar gravity, Lifespan lifetime) : base(lifetime) { this.location = location; this.gravity = gravity; }
public LineFluidLogic( Line line, Scalar dragCoefficient, Scalar density, Vector2D fluidVelocity, Lifespan lifetime) : base(lifetime) { this.line = line; this.dragCoefficient = dragCoefficient; this.density = density; this.fluidVelocity = fluidVelocity; this.Order = 1; this.items = new List<Wrapper>(); }
/// <summary> /// Creates a new GravityField Instance. /// </summary> /// <param name="gravity">The direction and magnitude of the gravity.</param> /// <param name="lifeTime">A object Describing how long the object will be in the engine.</param> public GravityField(Vector2D gravity, Lifespan lifetime) : base(lifetime) { this.gravity = gravity; }