NAME
Kafka::Cluster - object interface to manage a test kafka cluster.
VERSION
This documentation refers to Kafka::Cluster version 0.800_2 .
SYNOPSIS
# For examples see:
# t/??_cluster.t, t/??_cluster_start.t, t/??_connection.t, t/??_cluster_stop.t
DESCRIPTION
This module is not a user module.
The main features of the Kafka::Cluster module are:
Automatic start and stop the zookeeper server.
Start-up, re-initialize, stop the kafka servers cluster.
The servers automatically uses free ports.
Create, delete the data structures used by servers.
Getting information about the used servers.
Connection to an earlier running cluster.
The ability to perform a query to necessary server cluster.
EXPORT
These variables are the constants and never change their values.
$START_PORT
The port used to start the search of free ports - 9094. Zookeeper server uses the first available port.
$DEFAULT_TOPIC
Used topic name.
CONSTRUCTOR
new
Starts the server required for cluster or provides the ability to connect to a running cluster. In the first call in start-up, also launching a zookeeper server. Creates a Kafka::Cluster object.
An error will cause the program to halt.
To identify a particular server in the cluster port is used. The structures of these servers are created in the t/data.
new() takes arguments in key-value pairs. The following arguments are currently recognized:
kafka_dir => $kafka_dir-
The root directory of the Kafka installation.
cluster_factor => $cluster_factor-
Number kafka servers belonging to the generated cluster.
Optional, default = 3.
does_not_start => $does_not_start-
Sign of the need to connect to the already created cluster.
Optional, default = false (create and run a new cluster).
t_dir => $t_dir-
The required data structures are prepared to work in the directory
t/. When connected to a cluster from another directory, you must specify the path to the directoryt/.Optional - not specified (operation carried out in the directory
t/).
METHODS
The following methods are defined for the Kafka::Cluster class:
base_dir
Returns the root directory of the installation of Kafka.
log_dir( $port )
Constructs and returns the path to the data directory kafka server with the specified port.
This function take argument. The following argument is currently recognized:
servers
Returns a sorted list of ports kafka servers in the cluster.
node_id( $port )
Returns the node ID assigned by kafka server in the cluster. Returns C <undef>, if the server does not have an ID or a server with the specified port is not in the cluster.
This function take argument. The following argument is currently recognized:
zookeeper_port
Returns the port number used by zookeeper server.
init
Initializes the data structures used by kafka servers. At initialization, all the servers are stopped and deleted the data structure used by them. Zookeeper server does not stop, his data structure does not remove.
stop( $port )
Stops kafka server with the specified port. Stop all servers in the cluster, if the port is not specified.
This function take argument. The following argument is currently recognized:
start( $port )
Starts (restarts) kafka server with the specified port. Starts (restarts) all servers in the cluster, if the port is not specified.
This function take argument. The following argument is currently recognized:
request( $port, $bin_stream, $without_response )
Kafka server transmits a string of binary query retrieves and returns a binary response. No response is expected, and returns an empty string if the argument $without_response is true.
Kafka server is identified by the specified port.
This function take arguments. The following arguments is currently recognized:
$port-
$portdenoting the port number of the kafka service. The$portshould be a number. $bin_stream-
$bin_streamdenoting an empty binary string of the request to kafka server.
is_run_in_base_dir
Returns true, if the work is performed in the root directory of the installation Kafka.
close
Stop all production servers (including the zookeeper server). Deletes all data directories used by the servers. After execution, the t/data catalog does not contain service files.
DIAGNOSTICS
Error will causes to die automatically. The error message will be displayed on the console.
SEE ALSO
The basic operation of the Kafka package modules:
Kafka - constants and messages used by the Kafka package modules.
Kafka::Connection - interface to connect to a Kafka cluster.
Kafka::Producer - interface for producing client.
Kafka::Consumer - interface for consuming client.
Kafka::Message - interface to access Kafka message properties.
Kafka::Int64 - functions to work with 64 bit elements of the protocol on 32 bit systems.
Kafka::Protocol - functions to process messages in the Apache Kafka's Protocol.
Kafka::IO - low level interface for communication with Kafka server.
Kafka::Internals - Internal constants and functions used by several package modules.
A wealth of detail about the Apache Kafka and the Kafka Protocol:
Main page at http://kafka.apache.org/
Kafka Protocol at https://cwiki.apache.org/confluence/display/KAFKA/A+Guide+To+The+Kafka+Protocol
AUTHOR
Sergey Gladkov, <sgladkov@trackingsoft.com>
CONTRIBUTORS
Alexander Solovey
Jeremy Jordan
Vlad Marchenko
COPYRIGHT AND LICENSE
Copyright (C) 2012-2013 by TrackingSoft LLC.
This package is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See perlartistic at http://dev.perl.org/licenses/artistic.html.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.