Esempio n. 1
0
 def get_entry_history_written_time_range_list(self, pql, valid_at_time,
                                               from_written_time,
                                               to_written_time):
     '''Returns the temporal entries that satisfy the specified valid-at and end written time range for the given PQL query string. 
  
         Note that this method may retrieve one or more valid objects per temporal list.
         It searches temporal values that fall in the specified written time range.
     
     Args:
         pql: Pado query statement
         identity_key: Temporal identity key.
         valid_at_time: Valid at time in msec.
         from_written_time: Start of the written time range. -1 for current time.
         to_written_time: End of the written time range. -1 for current time.
         
     Returns: 
         Array of temporal entries in JSON key/value pairs.
     '''
     jparams = json.loads('{}')
     jparams['queryStatement'] = pql
     jparams['validAtTime'] = valid_at_time
     jparams['fromWrittenTime'] = from_written_time
     jparams['toWrittenTime'] = to_written_time
     jrequest = create_request(self._biz_class_name,
                               'getEntryHistoryWrittenTimeRangeList',
                               jparams)
     return self.rpc.execute(self.rpc_context, jrequest, 0)
Esempio n. 2
0
 def remove_listener(self, listener_name, listener):
     '''Remove the specified listener
     
     Args:
         listener_name: Unique name of the listener.
         listener: Previously added Listener function or class method.
      
     Returns:
         Removal results in JSON RPC reply form.
         
     Example:
         path_biz = PathBiz(rpc_context, 'company/sales')
         path_biz.addListener('some_grid_path', some_grid_path_rpc_listener)
         path_biz.removeListener('some_grid_path', some_grid_path_rpc_listener)
         
         def some_grid_path_rpc_listener(message):
             print('message=' + str(message))
     '''
     jparams = json.loads('{}')
     jparams['gridPath'] = self._grid_path
     jparams['name'] = listener_name
     jrequest = create_request(self._biz_class_name, 'removeListener',
                               jparams)
     self.rpc.remove_rpc_listener(listener_name, listener)
     return self.rpc.execute(self.rpc_context, jrequest, 0)
Esempio n. 3
0
 def invoke(self, jparams):
     print('rpc_invoker_dna.invoke() entered')
     if not 'classname' in jparams:
         return None
     rpc_class_name = jparams['classname']
     if not 'method' in jparams:
         return None 
     method = jparams['method']
     if not 'method' in jparams:
         rpc_params = None
     else:
         rpc_params = jparams['params']
     if not 'timeout' in jparams:
         timeout = 10000
     else:
         timeout = jparams['timeout']
     
     print('rpc_invoker_dna.invoke(): timeout=' + str(timeout))
     jrequest = create_request(rpc_class_name, method, rpc_params)
     print('rpc_invoker_dna.invoke(): jrequest=' + str(jrequest))
     jresult = self.rpc.execute(self.rpc_context, jrequest, timeout)
     if 'error' in jresult:
         error = jresult['error']
         return rpc_util.create_error_wrap(jerror=error)
     else:
         if 'result' in jresult:
             return jresult['result']
         else:
             return None
Esempio n. 4
0
 def put(self,
         identity_key,
         value,
         start_valid_time=-1,
         end_valid_time=-1,
         written_time=-1):
     '''Puts the specified (identity_key, value) in the temporal grid path.
     
     Args:
         identity_key: Temporal identity key
         value: Value to put in the grid path
         start_valid_time: Start valid time in msec since epoch time of January 1, 1970, 00:00:00 (UTC).
             If -1, then the current time. Default: -1
         end_valid_time: End valid time in msec since epoch time of January 1, 1970, 00:00:00 (UTC).
             If -1, then the current time. Default: -1
         written_time: Written time in msec since epoch time of January 1, 1970, 00:00:00 (UTC).
             If -1, then the current time. Default: -1
         
     Returns: 
         N/A.
     '''
     jparams = json.loads('{}')
     jparams['gridPath'] = self._grid_path
     jparams['identityKey'] = identity_key
     jparams['value'] = value
     jparams['startValidTime'] = start_valid_time
     jparams['endValidTime'] = end_valid_time
     jparams['writtenTime'] = written_time
     jrequest = create_request(self._biz_class_name, 'put', jparams)
     return self.rpc.execute(self.rpc_context, jrequest, 0)
Esempio n. 5
0
 def size(self):
     '''Gets the size of the grid path in the data node.
     
     Returns: Size in JSON RPC reply form.
     '''
     jparams = json.loads('{}')
     jparams['gridPath'] = self._grid_path
     jrequest = create_request(self._biz_class_name, 'size', jparams)
     return self.rpc.execute(self.rpc_context, jrequest, 0)
Esempio n. 6
0
 def dump_grid_path(self):
     '''Dump the grid path contents in the default data node dump directory.
     
     Returns: Execution results in JSON.
     '''
     jparams = json.loads('{}')
     jparams['gridPath'] = self._grid_path
     jrequest = create_request(self._biz_class_name, 'dumpGridPath',
                               jparams)
     return self.rpc.execute(self.rpc_context, jrequest, 0)
Esempio n. 7
0
 def get_all(self, key_array):
     '''Gets the values of the specified keys from the grid path.
     
     Args:
         key: JSON array of keys. Keys must be of string or numeric type.
         
     Returns: JSON object containing (key, value) pairs.
     '''
     jparams = json.loads('{}')
     jparams['gridPath'] = self._grid_path
     jparams['keyArray'] = key_array
     jrequest = create_request(self._biz_class_name, 'getAll', jparams)
     return self.rpc.execute(self.rpc_context, jrequest, 0)
Esempio n. 8
0
 def get(self, key):
     '''Gets the value of the specified key from the grid path.
     
     Args:
         key: Key of string or numeric type.
         
     Returns: Key mapped value in the grid path.
     '''
     jparams = json.loads('{}')
     jparams['gridPath'] = self._grid_path
     jparams['key'] = key
     jrequest = create_request(self._biz_class_name, 'get', jparams)
     return self.rpc.execute(self.rpc_context, jrequest, 0)
Esempio n. 9
0
 def remove(self, key):
     '''Removes the specified key from the grid path.
     
     Args:
         key: Key to remove. Must be of string or numeric type.
         
     Returns: Removed value.
     '''
     jparams = json.loads('{}')
     jparams['gridPath'] = self._grid_path
     jparams['key'] = key
     jrequest = create_request(self._biz_class_name, 'remove', jparams)
     return self.rpc.execute(self.rpc_context, jrequest, 0)
Esempio n. 10
0
 def put_all(self, entry_map):
     '''Puts the entries on the specified map the grid path.
     
     Args:
         entry_map: (key, value) entries. Must be of JSON type.
         
     Returns: void
     '''
     jparams = json.loads('{}')
     jparams['gridPath'] = self._grid_path
     jparams['entryMap'] = entry_map
     jrequest = create_request(self._biz_class_name, 'putAll', jparams)
     return self.rpc.execute(self.rpc_context, jrequest, 0)
Esempio n. 11
0
 def get_temporal_list_count(self):
     '''Returns the total count of temporal lists. The returned number represents the total number of unique identity keys.
     
     Args:
         N/A
         
     Returns: 
         Count in integer.
     '''
     jparams = json.loads('{}')
     jparams['gridPath'] = self._grid_path
     jrequest = create_request(self._biz_class_name, 'getTemporalListCount',
                               jparams)
     return self.rpc.execute(self.rpc_context, jrequest, 0)
Esempio n. 12
0
 def get_temporal_list(self, identity_key):
     '''Returns the temporal list of the specified identity key. A temporal list reflects a history of a given identity key.
     
     Args:
         identity_key: Identity key
         
     Returns: 
         None if the specified identity key is not found.
     '''
     jparams = json.loads('{}')
     jparams['gridPath'] = self._grid_path
     jparams['identityKey'] = identity_key
     jrequest = create_request(self._biz_class_name, 'getTemporalList',
                               jparams)
     return self.rpc.execute(self.rpc_context, jrequest, 0)
Esempio n. 13
0
 def size(self, valid_at_time=-1, as_of_time=-1):
     '''Returns the total count of entries that satisfy the specified valid-at and as-of times.
     
     Args:
         valid_at_time: The time at which the value is valid. If -1, then current time.
         as_of_time: The as-of time compared against the written times. If -1, then current time.
         
     Returns: Size in integer.
     '''
     jparams = json.loads('{}')
     jparams['gridPath'] = self._grid_path
     jparams['validAtTime'] = valid_at_time
     jparams['asOfTime'] = as_of_time
     jrequest = create_request(self._biz_class_name, 'size', jparams)
     return self.rpc.execute(self.rpc_context, jrequest, 0)
Esempio n. 14
0
 def put(self, key, value):
     '''Puts the specified (key, value) pair in the grid path.
     
     Args:
         key: Key of string or numeric type.
         value: Value of string, numeric or JSON object (JSON array not supported)
         
     Returns: Value put in the grid path
     '''
     jparams = json.loads('{}')
     jparams['gridPath'] = self._grid_path
     jparams['key'] = key
     jparams['value'] = value
     jrequest = create_request(self._biz_class_name, 'put', jparams)
     return self.rpc.execute(self.rpc_context, jrequest, 0)
Esempio n. 15
0
 def query(self, queryPredicate):
     '''Execute the specified query predicate on the grid path.
     
     Args:
         queryPredicate: Query predicate is a where clause with out the select projection.
         
     Returns: Query results in JSON RPC reply form
     
     Example:
         query("value['Name']='Smith'")
     '''
     jparams = json.loads('{}')
     jparams['gridPath'] = self._grid_path
     jparams['queryPredicate'] = queryPredicate
     jrequest = create_request(self._biz_class_name, 'query', jparams)
     return self.rpc.execute(self.rpc_context, jrequest, 0)
Esempio n. 16
0
 def execute_pql(self, pql, fetch_size=None):
     '''Execute the specified PQL (Pado Query Language.
     
     Args:
         pql: Pado query statement
         fetch_size: Fetch size per page. This is an optional parameter. The default value is configured by the server.
         
     Returns:
         Query results in JSON RPC reply form.
     '''
     jparams = json.loads('{}')
     jparams['pql'] = pql
     if fetch_size != None:
         jparams['fetchSize'] = fetch_size
     jrequest = create_request(self._biz_class_name, 'executePql', jparams)
     return self.rpc.execute(self.rpc_context, jrequest, 0)
Esempio n. 17
0
 def get(self, identity_key, valid_at_time=-1, as_of_time=-1):
     '''Returns the latest value as of now mapped by the specified identity key.
     
     Args:
         identity_key: Temporal identity key
         
     Returns: 
         Latest value of the specified identity key. None if not found.
     '''
     jparams = json.loads('{}')
     jparams['gridPath'] = self._grid_path
     jparams['identityKey'] = identity_key
     jparams['validAtTime'] = valid_at_time
     jparams['asOfTime'] = as_of_time
     jrequest = create_request(self._biz_class_name, 'get', jparams)
     return self.rpc.execute(self.rpc_context, jrequest, 0)
Esempio n. 18
0
 def dump_temporal_lists(self, dump_dir, identity_keys):
     '''Dumps the temporal lists of the the specified identity keys in the specified directory.
     
     Args:
         dump_dir: Directory in which the temporal lists are dumped. If null, then the server
             specified default directory is used. If directory does not exist, it is created.
         identity_keys: Array of identity keys
         
     Returns: 
         None if the identity keys are not specified or JSON object containing "dumpDir"
         and "fileMap". "fileMap" contains ("identityKey", "fileName") entries.
     '''
     jparams = json.loads('{}')
     jparams['gridPath'] = self._grid_path
     jparams['dumpDir'] = dump_dir
     jparams['identityKeys'] = identity_keys
     jrequest = create_request(self._biz_class_name, 'dump_temporal_lists',
                               jparams)
     return self.rpc.execute(self.rpc_context, jrequest, 0)
Esempio n. 19
0
 def get_all_entries(self, identity_key, valid_at_time=-1, as_of_time=-1):
     '''Returns all temporal entries of the specified identity key as of now.
     
     Args:
         identity_key: Temporal identity key.
         valid_at_time: Valid at time in msec.
         as_of_time: As of time in msec.
         
     Returns: 
         A chronologically ordered set providing a history of changes that
         fall in the valid-at time. The entries are ordered by start-valid and
         written times.
     '''
     jparams = json.loads('{}')
     jparams['gridPath'] = self._grid_path
     jparams['identityKey'] = identity_key
     jparams['validAtTime'] = valid_at_time
     jparams['asOfTime'] = as_of_time
     jrequest = create_request(self._biz_class_name, 'getAllEntries',
                               jparams)
     return self.rpc.execute(self.rpc_context, jrequest, 0)
Esempio n. 20
0
 def dump_all_temporal_lists(self, dump_dir):
     '''Dumps all of the temporal lists in the data node.
     
     IMPORTANT: This method may take a significant amount of time to complete if there are
         many identity keys. It is recommended to inovoke dump_temporal_lists() instead
         for faster execution and put less load on the grid.
     
     Args:
         dump_dir: Directory in which the temporal lists are dumped. If null, then the server
             specified default directory is used. If directory does not exist, it is created.
         
     Returns: 
         None if the identity keys are not specified or JSON object containing "dumpDir"
         and "fileMap". "fileMap" contains ("identityKey", "fileName") entries.
     '''
     jparams = json.loads('{}')
     jparams['gridPath'] = self._grid_path
     jparams['dumpDir'] = dump_dir
     jrequest = create_request(self._biz_class_name, 'dumpAllTemporalLists',
                               jparams)
     return self.rpc.execute(self.rpc_context, jrequest, 0)
Esempio n. 21
0
 def next_result_set(self, jresult):
     '''Return the next result set of the query result.
     
     Args:
         jresult: The returned result of execute_pql() or this method.
 
     Returns:
         None if the end of the result is reached.
     '''
     if jresult == None:
         return None
     if 'result' not in jresult:
         return None
     result = jresult['result']
     if 'pql' not in result:
         return None
     else:
         pql = result['pql']
     if 'nextBatchIndexOnServer' not in result:
         nextBatchIndexOnServer = -1
     else:
         nextBatchIndexOnServer = result['nextBatchIndexOnServer']
     if nextBatchIndexOnServer < 0:
         return None
     if 'totalSizeOnServer' not in result:
         totalSizeOnServer = -1
     else:
         totalSizeOnServer = result['totalSizeOnServer']
     if nextBatchIndexOnServer >= totalSizeOnServer:
         return None
     
     startIndex = nextBatchIndexOnServer   
     jparams = json.loads('{}')
     jparams['pql'] = pql
     jparams['startIndex'] = startIndex
     if 'fetchSize' in result:
         fetchSize = result['fetchSize']
         jparams['fetchSize'] = fetchSize
     jrequest2 = create_request(self._biz_class_name, 'executePql', jparams)
     return self.rpc.execute(self.rpc_context, jrequest2, 0)
Esempio n. 22
0
 def add_listener(self, listener_name, listener):
     '''Adds a listener to listen on data changes made in the grid path
     
     Args:
         listener_name: Unique name of the listener.
         listener: Listener function or class method with one parameter for receiving JSON messages.
         
     Returns:
         Addition results in JSON RPC reply form.
         
     Example:
         path_biz = PathBiz(rpc_context, 'company/sales')
         path_biz.addListener('some_grid_path', some_grid_path_rpc_listener)
         def some_grid_path_rpc_listener(message):
             print('message=' + str(message))
     '''
     jparams = json.loads('{}')
     jparams['gridPath'] = self._grid_path
     jparams['name'] = listener_name
     jrequest = create_request(self._biz_class_name, 'addListener', jparams)
     self.rpc.add_rpc_listener(listener_name, listener)
     return self.rpc.execute(self.rpc_context, jrequest, 0)