Exemple #1
0
    def __init__(self,
                 storage_client_settings=(),
                 namespace="public",
                 **kwargs):
        # init the storage client settings
        self.storage_client_settings =\
            types.StorageClientSettings(*storage_client_settings)
        __logger__.info("Creating a storage client to cluster '%s'",
                        self.storage_client_settings.service_uri)

        service_uri = ServiceURI(self.storage_client_settings.service_uri)
        assert service_uri.service_name.lower() == 'bk'

        # create channel
        self.__channel__ = grpc.insecure_channel(
            target=service_uri.service_location)
        __logger__.info(
            "Successfully created a storage client to cluster '%s'",
            self.storage_client_settings.service_uri)

        # create the rpc stub
        self.__root_range__ = RootRangeServiceStub(channel=self.__channel__)

        # assign the namespace
        self.__namespace__ = namespace
Exemple #2
0
def test_service_uri_multiple_hosts_mixed_with_and_without_port():
    uri = ServiceURI("bk://127.0.0.1:3181,127.0.0.2,127.0.0.3:5181")
    assert "bk" == uri.service_name
    assert uri.service_user is None
    assert "127.0.0.1:3181,127.0.0.2:4181,127.0.0.3:5181" == uri.service_location
    assert ["127.0.0.1:3181", "127.0.0.2:4181", "127.0.0.3:5181"] == uri.service_hosts
Exemple #3
0
def test_service_uri_one_host_with_port():
    uri = ServiceURI("bk://127.0.0.1:3181")
    assert "bk" == uri.service_name
    assert uri.service_user is None
    assert "127.0.0.1:3181" == uri.service_location
    assert ["127.0.0.1:3181"] == uri.service_hosts