forked from microsoft/GraphEngine
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTrinityConfig.cs
More file actions
141 lines (128 loc) · 4.4 KB
/
TrinityConfig.cs
File metadata and controls
141 lines (128 loc) · 4.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
// Graph Engine
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE.md file in the project root for full license information.
//
using System;
using Trinity.Network;
using Trinity.Diagnostics;
using Trinity.Core.Lib;
using System.IO;
using System.Runtime.InteropServices;
using Trinity.Configuration;
using Trinity.Utilities;
using System.Linq;
namespace Trinity
{
/// <summary>
/// Specifies the running modes supported by Trinity. This is obsolete.
/// </summary>
public enum RunningMode : int
{
/// <summary>
///Embedded (in-process) mode.
/// </summary>
Embedded,
/// <summary>
/// As a server.
/// </summary>
Server,
/// <summary>
/// As a proxy.
/// </summary>
Proxy,
/// <summary>
/// As a client.
/// </summary>
Client,
}
/// <summary>
/// A class for accessing and manipulating various system parameters.
/// </summary>
public unsafe static partial class TrinityConfig
{
#region Fields
internal static bool is_config_loaded = false;
private static object config_load_lock = new object();
internal const bool RWTimeout = false;
#endregion
/// <summary>
/// Static constructor
/// </summary>
static TrinityConfig()
{
GetConfigurationInstances().ToList();
}
/// <summary>
/// Gets or sets the running mode of current Trinity process.
/// The setter of this property is obsolete and is kept for backward compatibility.
/// Assigning a running mode to this property does not affect the system behavior.
/// </summary>
public static RunningMode CurrentRunningMode
{
get { return s_current_cluster_config.RunningMode; }
set { s_current_cluster_config.RunningMode = value; }
}
/// <summary>
/// Current system logging logLevel, default is LogLevel.Info.
/// </summary>
public static LogLevel LoggingLevel
{
get { return LoggingConfig.Instance.LoggingLevel; }
set { LoggingConfig.Instance.LoggingLevel = value; }
}
/// <summary>
/// Sets the directory for writing logs into.
/// </summary>
internal static string LogDirectory
{
get { return LoggingConfig.Instance.LogDirectory; }
set { LoggingConfig.Instance.LogDirectory = value; }
}
/// <summary>
/// Gets and Sets the bool value to represent whether to echo log entry on the standard output.
/// </summary>
public static bool LogEchoOnConsole
{
get { return LoggingConfig.Instance.LogEchoOnConsole; }
set { LoggingConfig.Instance.LogEchoOnConsole = value; }
}
/// <summary>
/// Gets and Sets the bool value to represent whether to stream log entries to a file on disk.
/// </summary>
public static bool LogToFile
{
get { return LoggingConfig.Instance.LogToFile; }
set { LoggingConfig.Instance.LogToFile = value; }
}
/// <summary>
/// Provides a local testing configuration with one server (localhost).
/// </summary>
internal static bool LocalTest
{
set
{
if (value)
{
Servers.Clear();
Proxies.Clear();
ServerInfo server = ServerInfo._LegacyCreateServerInfo(
hostName: "127.0.0.1",
port: TrinityConfig.CurrentClusterConfig.ServerPort,
assemblyPath: AssemblyUtility.MyAssemblyPath,
storageRoot: AssemblyUtility.MyAssemblyPath + "storage\\",
loggingLevel: LogLevel.Debug.ToString(),
availabilityGroup: "0");
switch (CurrentClusterConfig.RunningMode)
{
case RunningMode.Server:
TrinityConfig.AddServer(server);
break;
case RunningMode.Proxy:
TrinityConfig.AddProxy(server);
break;
}
}
}
}
}
}