예제 #1
0
            public override void Run()
            {
                RandomValues randomValues = RandomValues.create();

                awaitLatch(StartSignal);
                while (!EndSignal.get())
                {
                    using (Transaction transaction = DatabaseService.beginTx())
                    {
                        try
                        {
                            int operationType = randomValues.NextIntValue(3).value();
                            switch (operationType)
                            {
                            case 0:
                                long targetNodeId = randomValues.NextLongValue(TotalNodes).value();
                                DatabaseService.getNodeById(targetNodeId).delete();
                                break;

                            case 1:
                                long nodeId = randomValues.NextLongValue(TotalNodes).value();
                                Node node   = DatabaseService.getNodeById(nodeId);
                                IDictionary <string, object> allProperties = node.AllProperties;
                                foreach (string key in allProperties.Keys)
                                {
                                    node.SetProperty(key, randomValues.NextValue().asObject());
                                }
                                break;

                            case 2:
                                Node nodeToUpdate = DatabaseService.createNode(Label.label("label10"));
                                nodeToUpdate.SetProperty("property", randomValues.NextValue().asObject());
                                break;

                            default:
                                throw new System.NotSupportedException("Unknown type of index operation");
                            }
                            transaction.Success();
                        }
                        catch (Exception)
                        {
                            transaction.Failure();
                        }
                    }
                }
            }