Exemple #1
0
  def testInitialization(self):
    """Tests the __init__ function."""
    test_redis_client = self._CreateRedisClient()

    session = sessions.Session()
    task = tasks.Task(session_identifier=session.identifier)

    test_reader = reader.RedisStorageReader(
        session.identifier, task.identifier, redis_client=test_redis_client)
    self.assertIsNotNone(test_reader)
Exemple #2
0
  def _CheckRedisTaskStoreReadyForMerge(self, task):
    """Checks if a Redis task is ready for merging with this session storage.

    If the task is ready to be merged, this method also sets the task's
    storage file size.

    Args:
      task (Task): task.

    Returns:
      bool: True if the task is ready to be merged.
    """
    reader = redis_reader.RedisStorageReader(task)
    reader.Open()
    is_ready = reader.IsFinalized()
    reader.Close()
    task.storage_file_size = 1000
    return is_ready
Exemple #3
0
    def CreateTaskStorageReader(cls, storage_format, task, path):
        """Creates a task storage reader.

    Args:
      storage_format (str): storage format.
      task (Task): task the storage changes are part of.
      path (str): path to the storage file.

    Returns:
      StorageReader: a storage reader or None if the storage file cannot be
          opened or the storage format is not supported.
    """
        if storage_format == definitions.STORAGE_FORMAT_SQLITE:
            return sqlite_reader.SQLiteStorageFileReader(path)

        if storage_format == definitions.STORAGE_FORMAT_REDIS:
            return redis_reader.RedisStorageReader(task.session_identifier,
                                                   task.identifier)

        return None