Documentation ¶
Index ¶
- func StartControlDBServer(cluster string, dataDir string, tlsEnabled bool, certFile, keyFile string)
- type ControlDBServer
- func (s *ControlDBServer) CreateConfigFile(ctx context.Context, cfg *pb.ConfigFile) (*pb.CreateConfigFileResponse, error)
- func (s *ControlDBServer) CreateDevice(ctx context.Context, dev *pb.Device) (*pb.CreateDeviceResponse, error)
- func (s *ControlDBServer) CreateService(ctx context.Context, svc *pb.Service) (*pb.CreateServiceResponse, error)
- func (s *ControlDBServer) CreateServiceAttr(ctx context.Context, attr *pb.ServiceAttr) (*pb.CreateServiceAttrResponse, error)
- func (s *ControlDBServer) CreateServiceMember(ctx context.Context, member *pb.ServiceMember) (*pb.CreateServiceMemberResponse, error)
- func (s *ControlDBServer) CreateServiceStaticIP(ctx context.Context, serviceip *pb.ServiceStaticIP) (*pb.CreateServiceStaticIPResponse, error)
- func (s *ControlDBServer) DeleteConfigFile(ctx context.Context, key *pb.ConfigFileKey) (*pb.DeleteConfigFileResponse, error)
- func (s *ControlDBServer) DeleteDevice(ctx context.Context, key *pb.DeviceKey) (*pb.DeleteDeviceResponse, error)
- func (s *ControlDBServer) DeleteService(ctx context.Context, key *pb.ServiceKey) (*pb.DeleteServiceResponse, error)
- func (s *ControlDBServer) DeleteServiceAttr(ctx context.Context, key *pb.ServiceAttrKey) (*pb.DeleteServiceAttrResponse, error)
- func (s *ControlDBServer) DeleteServiceMember(ctx context.Context, key *pb.ServiceMemberKey) (*pb.DeleteServiceMemberResponse, error)
- func (s *ControlDBServer) DeleteServiceStaticIP(ctx context.Context, key *pb.ServiceStaticIPKey) (*pb.DeleteServiceStaticIPResponse, error)
- func (s *ControlDBServer) GetConfigFile(ctx context.Context, key *pb.ConfigFileKey) (*pb.ConfigFile, error)
- func (s *ControlDBServer) GetDevice(ctx context.Context, key *pb.DeviceKey) (*pb.Device, error)
- func (s *ControlDBServer) GetService(ctx context.Context, key *pb.ServiceKey) (*pb.Service, error)
- func (s *ControlDBServer) GetServiceAttr(ctx context.Context, key *pb.ServiceAttrKey) (*pb.ServiceAttr, error)
- func (s *ControlDBServer) GetServiceMember(ctx context.Context, key *pb.ServiceMemberKey) (*pb.ServiceMember, error)
- func (s *ControlDBServer) GetServiceStaticIP(ctx context.Context, key *pb.ServiceStaticIPKey) (*pb.ServiceStaticIP, error)
- func (s *ControlDBServer) ListDevices(req *pb.ListDeviceRequest, stream pb.ControlDBService_ListDevicesServer) error
- func (s *ControlDBServer) ListServiceMembers(req *pb.ListServiceMemberRequest, ...) error
- func (s *ControlDBServer) ListServices(req *pb.ListServiceRequest, stream pb.ControlDBService_ListServicesServer) error
- func (s *ControlDBServer) Stop()
- func (s *ControlDBServer) UpdateServiceAttr(ctx context.Context, req *pb.UpdateServiceAttrRequest) (*pb.UpdateServiceAttrResponse, error)
- func (s *ControlDBServer) UpdateServiceMember(ctx context.Context, req *pb.UpdateServiceMemberRequest) (*pb.UpdateServiceMemberResponse, error)
- func (s *ControlDBServer) UpdateServiceStaticIP(ctx context.Context, req *pb.UpdateServiceStaticIPRequest) (*pb.UpdateServiceStaticIPResponse, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type ControlDBServer ¶
type ControlDBServer struct {
// contains filtered or unexported fields
}
ControlDBServer implements DBService server.
The server design needs to be scalable, to support like 100 services in one cluster, and 10,000 serviceMembers per service. Every cluster will run its own control db service. If one service needs to cross clusters, such as 2 aws regions, federation (could simply be the service init script) will coordinate it. For example, federation creates the services on each cluster with two-phases. Firstly create service with the initial status. After the services are created in all clusters, change status to active.
Design options, go with #2. 1. use kv DB such as levelDB or RocksDB. looks over complex? If something goes wrong, not easy to debug. For example, some bug causes data corrupted, or file system crashes. 2. simply use file and directory. cluster/service data could be separated, will not impact each other. could control how data is organized, such as version support, atomic write via rename, etc. Could have the simple common solution for scalability. Limits the max children of one directory. If have more children, create a new directory. The example directory hierarchy:
/rootDir/cluster0/device.v0 cluster0/device.v1 cluster0/service.v0 cluster0/service.v1 cluster0/servicedir/service0-uuid/attr.v0 service0-uuid/attr.v1 service0-uuid/serviceMemberdir/member0 service0-uuid/serviceMemberdir/... service0-uuid/serviceMemberdir/member1000 service0-uuid/configdir/configfile0 service0-uuid/configdir/... service0-uuid/configdir/configfile1000 ... service1000-uuid/ cluster0/serviceipdir/ipfile0 cluster0/serviceipdir/... cluster0/serviceipdir/ipfile1000
For device, one device has very small data. Could simply write all devices' assignments into a single file. Keep like the last 10 versions would be enough. Similar for service, all services will be kept in a single file.
func NewControlDBServer ¶
func NewControlDBServer(rootPath string, clusterName string) (*ControlDBServer, error)
func (*ControlDBServer) CreateConfigFile ¶
func (s *ControlDBServer) CreateConfigFile(ctx context.Context, cfg *pb.ConfigFile) (*pb.CreateConfigFileResponse, error)
func (*ControlDBServer) CreateDevice ¶
func (s *ControlDBServer) CreateDevice(ctx context.Context, dev *pb.Device) (*pb.CreateDeviceResponse, error)
func (*ControlDBServer) CreateService ¶
func (s *ControlDBServer) CreateService(ctx context.Context, svc *pb.Service) (*pb.CreateServiceResponse, error)
func (*ControlDBServer) CreateServiceAttr ¶
func (s *ControlDBServer) CreateServiceAttr(ctx context.Context, attr *pb.ServiceAttr) (*pb.CreateServiceAttrResponse, error)
func (*ControlDBServer) CreateServiceMember ¶
func (s *ControlDBServer) CreateServiceMember(ctx context.Context, member *pb.ServiceMember) (*pb.CreateServiceMemberResponse, error)
func (*ControlDBServer) CreateServiceStaticIP ¶ added in v0.8.1
func (s *ControlDBServer) CreateServiceStaticIP(ctx context.Context, serviceip *pb.ServiceStaticIP) (*pb.CreateServiceStaticIPResponse, error)
func (*ControlDBServer) DeleteConfigFile ¶
func (s *ControlDBServer) DeleteConfigFile(ctx context.Context, key *pb.ConfigFileKey) (*pb.DeleteConfigFileResponse, error)
func (*ControlDBServer) DeleteDevice ¶
func (s *ControlDBServer) DeleteDevice(ctx context.Context, key *pb.DeviceKey) (*pb.DeleteDeviceResponse, error)
func (*ControlDBServer) DeleteService ¶
func (s *ControlDBServer) DeleteService(ctx context.Context, key *pb.ServiceKey) (*pb.DeleteServiceResponse, error)
func (*ControlDBServer) DeleteServiceAttr ¶
func (s *ControlDBServer) DeleteServiceAttr(ctx context.Context, key *pb.ServiceAttrKey) (*pb.DeleteServiceAttrResponse, error)
func (*ControlDBServer) DeleteServiceMember ¶
func (s *ControlDBServer) DeleteServiceMember(ctx context.Context, key *pb.ServiceMemberKey) (*pb.DeleteServiceMemberResponse, error)
func (*ControlDBServer) DeleteServiceStaticIP ¶ added in v0.8.1
func (s *ControlDBServer) DeleteServiceStaticIP(ctx context.Context, key *pb.ServiceStaticIPKey) (*pb.DeleteServiceStaticIPResponse, error)
func (*ControlDBServer) GetConfigFile ¶
func (s *ControlDBServer) GetConfigFile(ctx context.Context, key *pb.ConfigFileKey) (*pb.ConfigFile, error)
func (*ControlDBServer) GetService ¶
func (s *ControlDBServer) GetService(ctx context.Context, key *pb.ServiceKey) (*pb.Service, error)
func (*ControlDBServer) GetServiceAttr ¶
func (s *ControlDBServer) GetServiceAttr(ctx context.Context, key *pb.ServiceAttrKey) (*pb.ServiceAttr, error)
func (*ControlDBServer) GetServiceMember ¶
func (s *ControlDBServer) GetServiceMember(ctx context.Context, key *pb.ServiceMemberKey) (*pb.ServiceMember, error)
func (*ControlDBServer) GetServiceStaticIP ¶ added in v0.8.1
func (s *ControlDBServer) GetServiceStaticIP(ctx context.Context, key *pb.ServiceStaticIPKey) (*pb.ServiceStaticIP, error)
func (*ControlDBServer) ListDevices ¶
func (s *ControlDBServer) ListDevices(req *pb.ListDeviceRequest, stream pb.ControlDBService_ListDevicesServer) error
func (*ControlDBServer) ListServiceMembers ¶
func (s *ControlDBServer) ListServiceMembers(req *pb.ListServiceMemberRequest, stream pb.ControlDBService_ListServiceMembersServer) error
func (*ControlDBServer) ListServices ¶
func (s *ControlDBServer) ListServices(req *pb.ListServiceRequest, stream pb.ControlDBService_ListServicesServer) error
func (*ControlDBServer) Stop ¶
func (s *ControlDBServer) Stop()
func (*ControlDBServer) UpdateServiceAttr ¶
func (s *ControlDBServer) UpdateServiceAttr(ctx context.Context, req *pb.UpdateServiceAttrRequest) (*pb.UpdateServiceAttrResponse, error)
func (*ControlDBServer) UpdateServiceMember ¶
func (s *ControlDBServer) UpdateServiceMember(ctx context.Context, req *pb.UpdateServiceMemberRequest) (*pb.UpdateServiceMemberResponse, error)
func (*ControlDBServer) UpdateServiceStaticIP ¶ added in v0.8.1
func (s *ControlDBServer) UpdateServiceStaticIP(ctx context.Context, req *pb.UpdateServiceStaticIPRequest) (*pb.UpdateServiceStaticIPResponse, error)