clusterlistener

package
v0.0.0-...-e1f8a17 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 7, 2019 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ClusterEventLogger

type ClusterEventLogger struct {
	Prefix string
}

ClusterEventLogger logs cluster event changes by glog.V(1) implementing clusterlistener.ShardEventProcessor

func (*ClusterEventLogger) OnShardCreateEvent

func (l *ClusterEventLogger) OnShardCreateEvent(cluster *topology.Cluster, resource *pb.StoreResource, shardInfo *pb.ShardInfo)

OnShardCreateEvent implements clusterlistener.ShardEventProcessor

func (*ClusterEventLogger) OnShardPromoteEvent

func (l *ClusterEventLogger) OnShardPromoteEvent(cluster *topology.Cluster, resource *pb.StoreResource, shardInfo *pb.ShardInfo)

OnShardPromoteEvent implements clusterlistener.ShardEventProcessor

func (*ClusterEventLogger) OnShardRemoveEvent

func (l *ClusterEventLogger) OnShardRemoveEvent(cluster *topology.Cluster, resource *pb.StoreResource, shardInfo *pb.ShardInfo)

OnShardRemoveEvent implements clusterlistener.ShardEventProcessor

func (*ClusterEventLogger) OnShardUpdateEvent

func (l *ClusterEventLogger) OnShardUpdateEvent(cluster *topology.Cluster, resource *pb.StoreResource, shardInfo *pb.ShardInfo, oldShardInfo *pb.ShardInfo)

OnShardUpdateEvent implements clusterlistener.ShardEventProcessor

type ClusterListener

type ClusterListener struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

ClusterListener listens to cluster topology changes, and maintains a connection pool to the servers.

func NewClusterListener

func NewClusterListener(clientName string) *ClusterListener

NewClusterListener creates a cluster listener in a data center. clientName is only for display purpose.

func (*ClusterListener) AddExistingKeyspace

func (clusterListener *ClusterListener) AddExistingKeyspace(keyspace string, clusterSize int, replicationFactor int)

AddExistingKeyspace registers one keyspace to listen for changes. This is used by store server. The keyspace should already exists in local store.

func (*ClusterListener) AddNewKeyspace

func (clusterListener *ClusterListener) AddNewKeyspace(keyspace string, clusterSize int, replicationFactor int) *topology.Cluster

AddNewKeyspace registers one keyspace to listen for changes. Mostly used by client APIs. The keyspace should be new in local store.

func (*ClusterListener) Debug

func (clusterListener *ClusterListener) Debug(prefix string)

Debug prints out the cluster detailed information.

func (*ClusterListener) GetCluster

func (clusterListener *ClusterListener) GetCluster(keyspace string) (r *topology.Cluster, found bool)

GetCluster gets the cluster of the keyspace in local data center

func (*ClusterListener) GetConnectionByShardId

func (clusterListener *ClusterListener) GetConnectionByShardId(keyspace string, shardId int, replica int) (net.Conn, error)

GetConnectionByShardId returns the connection to the shard

func (*ClusterListener) GetOrSetCluster

func (clusterListener *ClusterListener) GetOrSetCluster(keyspace string, clusterSize int, replicationFactor int) *topology.Cluster

GetOrSetCluster gets or creates the cluster of the keyspace in local data center.

func (*ClusterListener) GetShardId

func (clusterListener *ClusterListener) GetShardId(keyspace string, partitionKey []byte) (shardId int, partitionHash uint64)

GetShardId returns the shard id and partition hash based on the partition key

func (*ClusterListener) HasConnectedKeyspace

func (clusterListener *ClusterListener) HasConnectedKeyspace(keyspace string) bool

HasConnectedKeyspace checks whether the listener has the information of the keyspace or not.

func (*ClusterListener) RegisterShardEventProcessor

func (clusterListener *ClusterListener) RegisterShardEventProcessor(shardEventProcess ShardEventProcessor)

RegisterShardEventProcessor registers a ShardEventProcessor

func (*ClusterListener) RemoveKeyspace

func (clusterListener *ClusterListener) RemoveKeyspace(keyspace string)

RemoveKeyspace stops following changes of a keyspace.

func (*ClusterListener) SetUnixSocket

func (clusterListener *ClusterListener) SetUnixSocket(useUnixSocket bool)

SetUnixSocket whether or not use unix socket if available. Default to true. When client or gateway is on the same machine as the store server, using unix socket can avoid some network cost.

func (*ClusterListener) StartListener

func (clusterListener *ClusterListener) StartListener(ctx context.Context, master string)

StartListener keeps the listener connected to the master.

func (*ClusterListener) UnregisterShardEventProcessor

func (clusterListener *ClusterListener) UnregisterShardEventProcessor(shardEventProcess ShardEventProcessor)

UnregisterShardEventProcessor unregisters a ShardEventProcessor

type ShardEventProcessor

type ShardEventProcessor interface {
	OnShardCreateEvent(cluster *topology.Cluster, resource *pb.StoreResource, ShardInfo *pb.ShardInfo)
	OnShardUpdateEvent(cluster *topology.Cluster, resource *pb.StoreResource, ShardInfo *pb.ShardInfo, oldShardInfo *pb.ShardInfo)
	OnShardRemoveEvent(cluster *topology.Cluster, resource *pb.StoreResource, ShardInfo *pb.ShardInfo)
	OnShardPromoteEvent(cluster *topology.Cluster, resource *pb.StoreResource, ShardInfo *pb.ShardInfo)
}

ShardEventProcessor processes shard topology change events

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL