Example #1
0
        static void Main(string[] args)
        {
            TrinityConfig.AddServer(new Trinity.Network.ServerInfo("127.0.0.1", 5304, Global.MyAssemblyPath, Trinity.Diagnostics.LogLevel.Error));
            if (args.Length < 1)
            {
                Console.WriteLine("Please provide a command line parameter (-s|-c).");
                Console.WriteLine("  -s  Start as a distributed hashtable server.");
                Console.WriteLine("  -c  Start as a distributed hashtable client.");
                return;
            }

            if (args[0].Trim().ToLower().StartsWith("-s"))
            {
                DistributedHashtableServer server = new DistributedHashtableServer();
                server.Start();
                while (true)
                {
                    Thread.Sleep(1000);
                }
            }

            if (args[0].Trim().ToLower().StartsWith("-c"))
            {
                HandlingUserInput();
            }
        }
Example #2
0
        static Log()
        {
            TrinityC.Init();
            try
            {
                TrinityConfig.LoadTrinityConfig();
            }
            catch
            {
                Log.WriteLine(LogLevel.Error, "Failure to load config file, falling back to default log behavior");
            }

            string unitTestAssemblyName = "Microsoft.VisualStudio.QualityTools.UnitTestFramework";
            bool   isInUnitTest         = AppDomain.CurrentDomain.GetAssemblies()
                                          .Any(a => a.FullName.StartsWith(unitTestAssemblyName, StringComparison.Ordinal));

            if (isInUnitTest)
            {
                WriteLine(LogLevel.Info, "UnitTestFramework detected. Enabling echo callback.");
                var LogFilename = Path.Combine(TrinityConfig.LogDirectory, "trinity-[" + DateTime.Now.ToStringForFilename() + "].log");
                new Thread(_unitTestLogEchoThread).Start(LogFilename);
            }

            BackgroundThread.AddBackgroundTask(new BackgroundTask(CollectLogEntries, c_LogEntryCollectorIdleInterval));
        }
Example #3
0
        static void Main(string[] args)
        {
            TrinityConfig.AddServer(new Trinity.Network.ServerInfo("127.0.0.1", 5304, Global.MyAssemblyPath, Trinity.Diagnostics.LogLevel.Error));

            if (args.Length >= 1 && args[0].StartsWith("-s"))
            {
                SSSPServer server = new SSSPServer();
                server.Start();
            }

            //SSSP.exe -c startcell
            if (args.Length >= 2 && args[0].StartsWith("-c"))
            {
                TrinityConfig.CurrentRunningMode = RunningMode.Client;
                for (int i = 0; i < Global.ServerCount; i++)
                {
                    using (var msg = new StartSSSPMessageWriter(long.Parse(args[1].Trim())))
                    {
                        Global.CloudStorage.StartSSSPToSSSPServer(i, msg);
                    }
                }
            }

            //SSSP.exe -q cellID
            if (args.Length >= 2 && args[0].StartsWith("-q"))
            {
                TrinityConfig.CurrentRunningMode = RunningMode.Client;
                var cell = Global.CloudStorage.LoadSSSPCell(int.Parse(args[1]));
                Console.WriteLine("Current vertex is {0}, the distance to the source vertex is {1}.",
                                  cell.CellID, cell.distance);
                while (cell.distance > 0)
                {
                    cell = Global.CloudStorage.LoadSSSPCell(cell.parent);
                    Console.WriteLine("Current vertex is {0}, the distance to the source vertex is {1}.",
                                      cell.CellID, cell.distance);
                }
            }

            //SSSP.exe -g node count
            if (args.Length >= 2 && args[0].StartsWith("-g"))
            {
                TrinityConfig.CurrentRunningMode = RunningMode.Client;

                Random rand      = new Random();
                int    nodeCount = int.Parse(args[1].Trim());
                for (int i = 0; i < nodeCount; i++)
                {
                    HashSet <long> neighbors = new HashSet <long>();
                    for (int j = 0; j < 10; j++)
                    {
                        long neighor = rand.Next(0, nodeCount);
                        if (neighor != i)
                        {
                            neighbors.Add(neighor);
                        }
                    }
                    Global.CloudStorage.SaveSSSPCell(i, distance: int.MaxValue, parent: -1, neighbors: neighbors.ToList());
                }
            }
        }
Example #4
0
        static void Main(string[] args)
        {
            // Trinity doesn't load the config file correctly if we don't tell it to.
            TrinityConfig.LoadConfig();
            TrinityConfig.CurrentRunningMode = RunningMode.Client;


            while (true)
            {
                string command = Console.ReadLine();
                long   id      = long.Parse(command.Split(' ')[1]);

                if (command.StartsWith("root"))
                {
                    StartSSSP(id);
                }
                else if (command.StartsWith("distance"))
                {
                    var cell = Global.CloudStorage.LoadSSSPCell(id);

                    Console.WriteLine("Distance: {0}", cell.distance);

                    Console.Write("Neighbors: ");
                    List <long> neighbors = cell.neighbors;
                    for (int i = 0; i < neighbors.Count; i++)
                    {
                        Console.Write("{0} ", neighbors[i]);
                    }
                    Console.WriteLine();
                }
            }
        }
Example #5
0
        static void Main(string[] args)
        {
            // Trinity doesn't load the config file correctly if we don't tell it to
            TrinityConfig.LoadConfig("trinity" + args[0] + ".xml");

            HITSServerImpl server = new HITSServerImpl();

            server.Start();


            if (loadData && Global.MyPartitionId == 0)
            {
                Console.WriteLine("Starting to load data");

                using (var reader = new StreamReader("Model_Journals_Fields.txt")) {
                    string         line;
                    string[]       fields;
                    long           currentNode = -1;
                    HashSet <long> references  = new HashSet <long>();

                    while ((line = reader.ReadLine()) != null)
                    {
                        try {
                            fields = line.Split();
                            long from = long.Parse(fields[0]);
                            long to   = long.Parse(fields[2]);


                            if (from == currentNode || currentNode == -1)
                            {
                                references.Add(to);
                                currentNode = from;
                            }
                            else
                            {
                                Global.CloudStorage.SaveJournal(currentNode, References: references.ToList(), HubScore: 0, OldHubScore: 0, AuthorityScore: 0, OldAuthorityScore: 0);
                                references.Clear();
                                references.Add(to);
                                currentNode = from;
                            }
                        } catch (Exception e) {
                            Console.WriteLine(e.ToString());
                        }
                    }
                    Global.CloudStorage.SaveStorage();
                    Console.WriteLine("Finished loading data");
                }
            }
            else if (Global.MyPartitionId == 0)
            {
                Global.CloudStorage.LoadStorage();
                Console.WriteLine("Finished loading data");
            }


            Console.ReadLine();

            server.Stop();
        }
Example #6
0
        /// <summary>
        /// Starts a Trinity instance.
        /// </summary>
        public void Start()
        {
            lock (m_lock)
            {
                if (m_started)
                {
                    return;
                }
                try
                {
                    Log.WriteLine(LogLevel.Debug, "Starting communication instance.");
                    var _config = TrinityConfig.CurrentClusterConfig;

                    _config.RunningMode          = this.RunningMode;
                    Global.CommunicationInstance = this;

                    if (_InstanceList.Count == 0)
                    {
                        Log.WriteLine(LogLevel.Warning, "No distributed instances configured. Turning on local test mode.");
                        TrinityConfig.LocalTest = true;
                    }

                    //  Initialize message handlers
                    MessageHandlers.Initialize();
                    RegisterMessageHandler();

                    //  Initialize message passing networking
                    NativeNetwork.StartTrinityServer((UInt16)_config.ListeningPort);
                    Log.WriteLine("My IPEndPoint: " + _config.MyBoundIP + ":" + _config.ListeningPort);

                    //  Initialize cloud storage
                    memory_cloud = Global.CloudStorage;

                    //  Initialize the modules
                    _InitializeModules();

                    if (HasHttpEndpoints())
                    {
                        StartHttpServer();
                    }

                    Console.WriteLine("Working Directory: {0}", Global.MyAssemblyPath);
                    Console.WriteLine(_config.OutputCurrentConfig());
                    Console.WriteLine(TrinityConfig.OutputCurrentConfig());

                    m_started = true;
                    Log.WriteLine("{0} {1} is successfully started.", RunningMode, _config.MyInstanceId);
                    _RaiseStartedEvents();
                }
                catch (Exception ex)
                {
                    Log.WriteLine(LogLevel.Error, "CommunicationInstance: " + ex.ToString());
                }
            }
        }
Example #7
0
 static Storage()
 {
     try
     {
         TrinityConfig.LoadTrinityConfig();
     }
     catch
     {
         Log.WriteLine(LogLevel.Error, "Failure to load config file, falling back to default Storage behavior");
     }
 }
Example #8
0
        static void Main(string[] args)
        {
            // Trinity doesn't load the config file correctly if we don't tell it to
            TrinityConfig.LoadConfig();
            TrinityConfig.CurrentRunningMode = RunningMode.Server;

            BFSServerImpl server = new BFSServerImpl();

            server.Start();

            Console.WriteLine("Starting to load data");

            using (var reader = new StreamReader("p2p-Gnutella31.txt")) {
                //using (var reader = new StreamReader("com-youtube.ungraph.txt")) {
                //using (var reader = new StreamReader("com-orkut.ungraph.txt")) {
                string      line;
                string[]    fields;
                long        currentNode = 0;
                List <long> neighbors   = new List <long>();

                while ((line = reader.ReadLine()) != null)
                {
                    try {
                        fields = line.Split(null);
                        long from = long.Parse(fields[0]);
                        long to   = long.Parse(fields[1]);



                        if (from == currentNode)
                        {
                            neighbors.Add(to);
                        }
                        else
                        {
                            Global.CloudStorage.SaveBFSCell(currentNode, level: int.MaxValue, parent: -1, neighbors: neighbors);
                            neighbors.Clear();
                            neighbors.Add(to);
                            currentNode = from;
                        }
                    } catch (Exception e) {
                        Console.WriteLine(e.ToString());
                        //break;
                    }
                }
            }



            Console.WriteLine("Finished loading data");
            Console.WriteLine("Press Enter to close");

            Console.ReadLine();
        }
Example #9
0
        static void Main(string[] args)
        {
            // Trinity doesn't load the config file correctly if we don't tell it to
            TrinityConfig.LoadConfig();
            TrinityConfig.CurrentRunningMode = RunningMode.Server;

            DistributedHashtableServer server = new DistributedHashtableServer();

            server.Start();

            Console.ReadKey();
        }
Example #10
0
        static void Main(string[] args)
        {
            // Trinity doesn't load the config file correctly if we don't tell it to
            TrinityConfig.LoadConfig();
            TrinityConfig.CurrentRunningMode = RunningMode.Server;
            // Create our PingServer implementation an start it.
            SimplePingServer server = new SimplePingServer();

            server.Start();

            Console.ReadKey();
        }
Example #11
0
 static LocalMemoryStorage()
 {
     TrinityC.Init();
     try
     {
         TrinityConfig.LoadTrinityConfig();
     }
     catch
     {
         Log.WriteLine(LogLevel.Error, "Failure to load config file, falling back to default LocalMemoryStorage behavior");
     }
     CSynchronizeStorageRoot();
 }
Example #12
0
        static void Main(string[] args)
        {
            // Trinity doesn't load the config file correctly if we don't tell it to
            TrinityConfig.LoadConfig();
            TrinityConfig.CurrentRunningMode = RunningMode.Server;
            SimpleBenchmarkServer server = new SimpleBenchmarkServer();

            server.Start();
            while (true)
            {
                Thread.Sleep(200);
            }
        }
Example #13
0
        static Log()
        {
            TrinityC.Init();
            try
            {
                TrinityConfig.LoadTrinityConfig();
            }
            catch
            {
                Log.WriteLine(LogLevel.Error, "Failure to load config file, falling back to default log behavior");
            }

            BackgroundThread.AddBackgroundTask(new BackgroundTask(CollectLogEntries, c_LogEntryCollectorIdleInterval));
        }
Example #14
0
        static void Main(string[] args)
        {
            // Trinity doesn't load the config file correctly if we don't tell it to.
            TrinityConfig.LoadConfig();
            //TrinityConfig.CurrentRunningMode = RunningMode.Proxy;
            //TrinityConfig.CurrentRunningMode = RunningMode.Client;

            CoordinatorImpl coordinator = new CoordinatorImpl();

            coordinator.Start();

            Coordinator.MessagePassingExtension.RunHITS(Global.CloudStorage.ProxyList[0]);

            //coordinator.RunHITSHandler();

            /*
             * ulong cellCount = GetCellCount();
             * Console.WriteLine("Journal Count: {0}", cellCount);
             *
             * double initialAuthScore = 1;
             * double initialHubScore = 1;
             *
             * SetInitialScores(initialHubScore, initialAuthScore);
             *
             * for (int  i = 0; i < 5; i++) {
             * Console.WriteLine("Starting Update Round: {0}", i);
             * AuthUpdate();
             * HubUpdate();
             * }
             *
             * Console.WriteLine("Top Authorities:");
             * Console.WriteLine("_________________");
             * List<long> topAuthorities = GetTopAuthorities();
             * foreach(long authorityId in topAuthorities) {
             * Journal authority = Global.CloudStorage.LoadJournal(authorityId);
             * Console.WriteLine("ID: {0}, Score: {1}", authority.CellId, authority.AuthorityScore);
             * }
             *
             *
             * Console.WriteLine("Top Hubs:");
             * Console.WriteLine("_________________");
             * List<long> topHubs = GetTopHubs();
             * foreach(long hubId in topHubs) {
             * Journal hub = Global.CloudStorage.LoadJournal(hubId);
             * Console.WriteLine("ID: {0}, Score: {1}", hub.CellId, hub.HubScore);
             * }
             */
        }
Example #15
0
 internal static void Initialize()
 {
     lock (s_init_lock)
     {
         if (s_initialized)
         {
             return;
         }
         TrinityConfig.EnsureConfig();
         CLogInitialize();
         s_bgtask = new BackgroundTask(CollectLogEntries, c_LogEntryCollectorIdleInterval);
         BackgroundThread.AddBackgroundTask(s_bgtask);
         s_initialized = true;
         s_logtofile   = LoggingConfig.Instance.LogToFile;
         SetLogDirectory(LoggingConfig.Instance.LogDirectory);
     }
 }
Example #16
0
        /// <summary>
        /// Starts a Trinity instance.
        /// </summary>
        public unsafe void Start()
        {
            lock (m_lock)
            {
                if (m_started)
                {
                    return;
                }
                try
                {
                    Log.WriteLine(LogLevel.Debug, "Starting communication instance.");
                    Global.CommunicationInstance     = this;
                    TrinityConfig.CurrentRunningMode = this.RunningMode;

                    //  Initialize message handlers
                    MessageHandlers.Initialize();
                    RegisterMessageHandler();
                    MessageDispatcher = _MessageInitializationTrap;

                    //  Bring up networking subsystems
                    StartCommunicationListeners();

                    //  Initialize cloud storage
                    memory_cloud = Global.CloudStorage;

                    //  Initialize the modules
                    _ScanForAutoRegisteredModules();
                    _InitializeModules();

                    //  Modules initialized, release pending messages from the trap
                    m_module_init_signal.Set();
                    MessageDispatcher = MessageHandlers.DefaultParser.DispatchMessage;

                    Log.WriteLine("Working Directory: {0}", Global.MyAssemblyPath);
                    Log.WriteLines(TrinityConfig.OutputCurrentConfig());

                    m_started = true;
                    Log.WriteLine("{0} {1} is successfully started.", RunningMode, memory_cloud.MyInstanceId);
                    _RaiseStartedEvents();
                }
                catch (Exception ex)
                {
                    Log.WriteLine(LogLevel.Error, "CommunicationInstance: " + ex.ToString());
                }
            }
        }
Example #17
0
        public Client(StatelessServiceContext context)
            : base(context)
        {
            TrinityConfig.LoadConfig();

            TrinityConfig.CurrentRunningMode = RunningMode.Client;
            TrinityConfig.LogEchoOnConsole   = false;
            TrinityConfig.LoggingLevel       = LogLevel.Debug;

            TrinityConfig.SaveConfig();

            Log.LogsWritten += Log_LogsWritten;

            TrinityTripleModuleClient = new TrinityClient("fabric:/GraphEngine.ServiceFabric.TripleStoreApplication/Stateful.TripleStore.GraphDataService");

            TrinityTripleModuleClient.UnhandledException += TrinityTripleModuleClient_UnhandledException1;
            TrinityTripleModuleClient.Started            += TrinityTripleModuleClientStarted;

            TrinityTripleModuleClient.Start();
        }
Example #18
0
        static void Main(string[] args)
        {
            // Trinity doesn't load the config file correctly if we don't tell it to.
            TrinityConfig.LoadConfig();
            TrinityConfig.CurrentRunningMode = RunningMode.Client;

            using (var request = new PingMessageWriter("Ping!1")) {
                Global.CloudStorage.SynPingToPingServer(0, request);
            }

            using (var request = new PingMessageWriter("Ping!2")) {
                Global.CloudStorage.AsynPingToPingServer(0, request);
            }

            using (var request = new PingMessageWriter("Ping!3")) {
                using (var response = Global.CloudStorage.SynEchoPingToPingServer(0, request)) {
                    Console.WriteLine("Server Response: {0}", response.Message);
                }
            }
        }
Example #19
0
        /// <summary>
        /// Initializes the LocalStorage instance.
        /// </summary>
        public LocalMemoryStorage()
        {
            TrinityConfig.EnsureConfig();
            CSynchronizeStorageRoot();

            if (TrinityErrorCode.E_SUCCESS != CLocalMemoryStorage.CInitialize())
            {
                //TODO more specific exception type
                throw new Exception();
            }

            // Register built-in storage event handlers
            StorageLoaded += InitializeWriteAheadLogFile;
            StorageLoaded += LoadCellTypeSignatures;
            StorageSaved  += CreateWriteAheadLogFile;
            StorageSaved  += SaveCellTypeSignatures;
            StorageReset  += ResetWriteAheadLog;

            InitializeWriteAheadLogFile();
            Thread.MemoryBarrier();
            initialized = true;
        }
Example #20
0
        static void Main(string[] args)
        {
            // Trinity doesn't load the config file correctly if we don't tell it to.
            TrinityConfig.LoadConfig();
            TrinityConfig.CurrentRunningMode = RunningMode.Client;

            while (true)
            {
                Console.WriteLine("Input a command 'set key value' 'get key'");
                string   input  = Console.ReadLine();
                string[] fields = input.Split(" ");

                int partitionId = GetPartitionIdByKey(fields[0]);

                if (fields[0] == "get")
                {
                    using (var request = new GetMessageWriter(fields[1])) {
                        using (var response = Global.CloudStorage.GetToDHTServer(partitionId, request)) {
                            if (response.IsFound)
                            {
                                Console.WriteLine("Key:  {0} ; Value: {1}", request.Key, response.Value);
                            }
                            else
                            {
                                Console.WriteLine("Key: {0} wasn't found", request.Key);
                            }
                        }
                    }
                }
                else if (fields[0] == "set")
                {
                    using (var request = new SetMessageWriter(fields[1], fields[2])) {
                        Global.CloudStorage.SetToDHTServer(partitionId, request);
                    }
                }
            }
        }
Example #21
0
        static void Main(string[] args)
        {
            // Trinity doesn't load the config file correctly if we don't tell it to.
            TrinityConfig.LoadConfig();
            TrinityConfig.CurrentRunningMode = RunningMode.Client;

            Program program = new Program();

            program.readCommandLineArguments(args);
            program.setConfiguration();
            if (args.Length > 0)
            {
                if (args[0] == "run_all")
                {
                    using (var request = new ConfigurationMessageWriter("Start/Loader"))
                    {
                        Global.CloudStorage.SynPingToBenchmarkServer(0, request);
                    }
                }
                if (args[0] == "run")
                {
                    program.Run();
                }
                if (args[0] == "verify")
                {
                    program.verifySetup();
                }
                if (args[0] == "load")
                {
                    program.LoadGraph();
                }
                if (args[0] == "delete")
                {
                    program.Delete();
                }
            }
            else
            {
                Console.WriteLine("#######################################################################");
                Console.WriteLine("Options: (to run with configuration add run [dotnet run run [OPTIONS]])");
                Console.WriteLine("--graph-name");
                Console.WriteLine("--input-vertex-path");
                Console.WriteLine("--input-edge-path");
                Console.WriteLine("--loutput-path");
                Console.WriteLine("--directed");
                Console.WriteLine("--weighted");
                Console.WriteLine("--ejob-id");
                Console.WriteLine("--elog-path");
                Console.WriteLine("--algorithm");
                Console.WriteLine("--source-vertex");
                Console.WriteLine("--max-iterations");
                Console.WriteLine("--damping-factor");
                Console.WriteLine("--input-path");
                Console.WriteLine("--eoutput-path");
                Console.WriteLine("--home-dir");
                Console.WriteLine("--num-machines");
                Console.WriteLine("--num-threads");
                Console.WriteLine("--tjob-id");
                Console.WriteLine("--tlog-path");
            }
        }
Example #22
0
 static Storage()
 {
     TrinityConfig.LoadTrinityConfig();
 }
Example #23
0
 static void Main(string[] args)
 {
     // Trinity doesn't load the config file correctly if we don't tell it to.
     TrinityConfig.LoadConfig();
     TrinityConfig.CurrentRunningMode = RunningMode.Client;
 }
Example #24
0
 public void saves_2_0_config_format()
 {
     TrinityConfig.SaveConfig("test.xml");
     Assert.That(File.ReadAllText("test.xml").Contains("ConfigVersion=\"2.0\""));
 }
Example #25
0
 public void saves_2_0_config_format()
 {
     TrinityConfig.SaveConfig("test.xml");
     Assert.True(File.ReadAllText(Path.Combine(AssemblyUtility.MyAssemblyPath, "test.xml")).Contains("ConfigVersion=\"2.0\""));
 }
Example #26
0
 public void load_config_no_exception_2()
 {
     TrinityConfig.LoadConfig("test2.xml");
 }
Example #27
0
 public void load_config_no_exception()
 {
     TrinityConfig.LoadConfig();
 }
Example #28
0
 public void save_config_no_exception_2()
 {
     TrinityConfig.SaveConfig("test2.xml");
 }
Example #29
0
 public void save_config_no_exception()
 {
     TrinityConfig.SaveConfig();
 }
 static LocalMemoryStorage()
 {
     InternalCalls.__init();
     TrinityConfig.LoadTrinityConfig();
     //BackgroundThread.StartMemoryStorageBgThreads();
 }