csle_collector.kafka_manager package
Submodules
csle_collector.kafka_manager.kafka_manager module
- class csle_collector.kafka_manager.kafka_manager.KafkaManagerServicer[source]
Bases:
csle_collector.kafka_manager.kafka_manager_pb2_grpc.KafkaManagerServicer
gRPC server for managing a Kafka server. Allows to start/stop the kafka server remotely and also to query the state of the server and create/delete topics.
- createTopic(request: kafka_manager_pb2.CreateTopicMsg, context: grpc.ServicerContext) kafka_manager_pb2.KafkaDTO [source]
Creates a new Kafka topic
- Parameters
request – the gRPC request
context – the gRPC context
- Returns
a clients DTO with the state of the kafka server
- getKafkaStatus(request: kafka_manager_pb2.GetKafkaStatusMsg, context: grpc.ServicerContext) kafka_manager_pb2.KafkaDTO [source]
Gets the state of the kafka server
- Parameters
request – the gRPC request
context – the gRPC context
- Returns
a clients DTO with the state of the kafka server
- csle_collector.kafka_manager.kafka_manager.serve(port: int = 50051, log_dir: str = '/', max_workers: int = 10, log_file_name: str = 'kafka_manager.log') None [source]
Starts the gRPC server for managing the kafka server
- Parameters
port – the port that the server will listen to
log_dir – the directory to write the log file
log_file_name – the file name of the log
max_workers – the maximum number of GRPC workers
- Returns
None
csle_collector.kafka_manager.kafka_manager_pb2 module
Generated protocol buffer code.
csle_collector.kafka_manager.kafka_manager_pb2_grpc module
Client and server classes corresponding to protobuf-defined services.
- class csle_collector.kafka_manager.kafka_manager_pb2_grpc.KafkaManager[source]
Bases:
object
Interface exported by the server
- static createTopic(request, target, options=(), channel_credentials=None, call_credentials=None, insecure=False, compression=None, wait_for_ready=None, timeout=None, metadata=None)[source]
- static deleteTopic(request, target, options=(), channel_credentials=None, call_credentials=None, insecure=False, compression=None, wait_for_ready=None, timeout=None, metadata=None)[source]
- static getKafkaStatus(request, target, options=(), channel_credentials=None, call_credentials=None, insecure=False, compression=None, wait_for_ready=None, timeout=None, metadata=None)[source]
- class csle_collector.kafka_manager.kafka_manager_pb2_grpc.KafkaManagerServicer[source]
Bases:
object
Interface exported by the server
csle_collector.kafka_manager.kafka_manager_util module
- class csle_collector.kafka_manager.kafka_manager_util.KafkaManagerUtil[source]
Bases:
object
Class with utility functions related to the Kafka Manager
- static hours_to_ms(hours: float) float [source]
Convert hours to ms
- Parameters
hours – the hours to convert
- Returns
the ms
csle_collector.kafka_manager.query_kafka_server module
- csle_collector.kafka_manager.query_kafka_server.create_topic(stub: csle_collector.kafka_manager.kafka_manager_pb2_grpc.KafkaManagerStub, name: str, partitions: int, replicas: int, retention_time_hours: int, timeout=60) kafka_manager_pb2.KafkaDTO [source]
Sends a request to the KafkaManager to create a new Kafka topic
- Parameters
stub – the stub to send the remote gRPC to the server
name – the name of the Kafka topic
partitions – the number of partitions of the Kafka topic
replicas – the number of replicas of the Kafka topic
retention_time_hours – the retention time for the topic
timeout – the GRPC timeout (seconds)
- Returns
a KafkaDTO describing the status of the kafka server
- csle_collector.kafka_manager.query_kafka_server.get_kafka_status(stub: csle_collector.kafka_manager.kafka_manager_pb2_grpc.KafkaManagerStub, timeout=60) kafka_manager_pb2.KafkaDTO [source]
Queries the server for the kafka server status
- Parameters
stub – the stub to send the remote gRPC to the server
timeout – the GRPC timeout (seconds)
- Returns
a KafkaDTO describing the status of the kafka server
- csle_collector.kafka_manager.query_kafka_server.start_kafka(stub: csle_collector.kafka_manager.kafka_manager_pb2_grpc.KafkaManagerStub, timeout=60) kafka_manager_pb2.KafkaDTO [source]
Sends a request to the Kafka server to start the Kafka server
- Parameters
stub – the stub to send the remote gRPC to the server
timeout – the GRPC timeout (seconds)
- Returns
a KafkaDTO describing the status of the kafka server
- csle_collector.kafka_manager.query_kafka_server.stop_kafka(stub: csle_collector.kafka_manager.kafka_manager_pb2_grpc.KafkaManagerStub, timeout=60) kafka_manager_pb2.KafkaDTO [source]
Sends a request to the Kafka server to stop the Kafka server
- Parameters
stub – the stub to send the remote gRPC to the server
timeout – the GRPC timeout (seconds)
- Returns
a KafkaDTO describing the status of the kafka server