示例#1
0
 public Statistics GetStatistics()
 {
     Command statisticsCommand = commandBuilder.buildStatisticsCommand(key,dbProperties.GetUserName(), dbProperties.GetPassword());
     distributionManager.produceTcp(statisticsCommand);
     long memorySize= statisticsCommand.getMemorySize();
     List<SessionMetaData> sessions=new List<SessionMetaData>();
     List<Command> sessionsCommands = statisticsCommand.getCommands();
     foreach (Command session in sessionsCommands) {
     String userName = session.GetUserName();
     String password = session.GetPassword();
     String ip = session.GetIp();
     int port = session.GetPort();
     int sessionId = session.GetSessionId();
     int coreManagerId = session.GetCoreManagerKey();
     int schemaId = session.GetSchemaId();
     long sessionLastAccess = session.GetSessionLastAccess();
     bool administrator = session.IsAdministratorUser();
     SessionMetaData sessionMetaData = new SessionMetaData(schemaId, "", userName, password,coreManagerId, sessionId, ip, port,administrator,sessionLastAccess);
     sessions.Add(sessionMetaData);
     }
     return new Statistics(memorySize,sessions);
 }
示例#2
0
 public Schema LoginToSchema(String schemaName)
 {
     if (schemaName == null)
     {
         throw new PlanckDBException(CommandStatus.unsupported, "Schema name can't be null");
     }
     String userName = dbProperties.GetUserName();
     String password = dbProperties.GetPassword();
     // The following dynamic flag should tel the server to broadcast changes to the client
     bool dynamic = true;
     Command command = commandBuilder.buildLoginCommand(userName, password, schemaName, getKey(), dynamic);
     distributionManager.produceTcp(command);
     Int32? schemaId = command.GetSchemaId();
     Int32 sessionId = command.GetSessionId();
     CommandStatus status = command.getStatus();
     if (CommandStatus.success.Equals(status))
     {
         SessionMetaData sessionMetaData = new SessionMetaData((int)schemaId, schemaName, userName, password, key, sessionId);
         return createSchema(sessionMetaData);
     }
     else if (CommandStatus.schemaDoesNotExist.Equals(status))
     {
         throw new SchemaDoesNotExistException(status, status.getMessage() + " : schema name : " + schemaName);
     }
     else
     {
         throw new PlanckDBException(status, status.getMessage() + " : schema name : " + schemaName);
     }
 }
示例#3
0
        public Schema createSchema(SessionMetaData sessionMetaData)
        {
            SchemaImpl schemaImpl;
            try
            {
                // activate injection process
                Type schemaClass = typeof(SchemaImpl);
                schemaImpl = (SchemaImpl)dependencyInjectorFactory.CreateInstance(schemaClass, sessionMetaData, dbProperties, this);
                FieldInfo property = schemaClass.GetField("core", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Public);
                Core core = (Core)property.GetValue(schemaImpl);

                // update schemaMap
                List<Schema> schemas = null;
                schemaMap.TryGetValue(sessionMetaData.getSchemaId(), out schemas);
                if (schemas == null)
                {
                    schemas = new CopyOnWriteArrayList<Schema>();
                    schemaMap[sessionMetaData.getSchemaId()] = schemas;
                }
                schemas.Add(schemaImpl);
                // update coresMap
                List<Core> cores = null;
                coreMap.TryGetValue(sessionMetaData.getSchemaId(), out cores);
                if (cores == null)
                {
                    cores = new CopyOnWriteArrayList<Core>();
                    coreMap[sessionMetaData.getSchemaId()] = cores;
                }
                cores.Add(core);
            }
            catch (Exception e)
            {
                throw new PlanckDBException(CommandStatus.unsupported, "unsupported state the should not reach to this point of the code" + e.Message);
            }
            return schemaImpl;
        }