Class ZooInspectorManagerImpl
- java.lang.Object
-
- org.apache.zookeeper.inspector.manager.ZooInspectorManagerImpl
-
- All Implemented Interfaces:
ZooInspectorManager
,ZooInspectorNodeManager
,ZooInspectorNodeTreeManager
,ZooInspectorReadOnlyManager
public class ZooInspectorManagerImpl extends java.lang.Object implements ZooInspectorManager
A default implementation ofZooInspectorManager
for connecting to zookeeper instances
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description class
ZooInspectorManagerImpl.NodeWatcher
A Watcher which will re-add itself every time an event is fired
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
AUTH_DATA_KEY
The key used for the authentication data in the connection properties filestatic java.lang.String
AUTH_SCHEME_KEY
The key used for the authentication scheme in the connection properties filestatic java.lang.String
CONNECT_STRING
The key used for the connect string in the connection properties fileprotected boolean
connected
static java.lang.String
DATA_ENCRYPTION_MANAGER
The key used for the data encryption manager in the connection properties filestatic java.lang.String
SESSION_TIMEOUT
The key used for the session timeout in the connection properties file
-
Constructor Summary
Constructors Constructor Description ZooInspectorManagerImpl()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addWatchers(java.util.Collection<java.lang.String> selectedNodes, NodeListener nodeListener)
boolean
connect(java.util.Properties connectionProps)
boolean
createNode(java.lang.String parent, java.lang.String nodeName)
boolean
deleteNode(java.lang.String nodePath)
boolean
disconnect()
java.util.List<java.util.Map<java.lang.String,java.lang.String>>
getACLs(java.lang.String nodePath)
java.util.List<java.lang.String>
getChildren(java.lang.String nodePath)
Pair<java.util.Map<java.lang.String,java.util.List<java.lang.String>>,java.util.Map<java.lang.String,java.lang.String>>
getConnectionPropertiesTemplate()
java.lang.String
getData(java.lang.String nodePath)
java.util.List<java.lang.String>
getDefaultNodeViewerConfiguration()
java.util.Properties
getLastConnectionProps()
java.util.Map<java.lang.String,java.lang.String>
getNodeMeta(java.lang.String nodePath)
int
getNumChildren(java.lang.String nodePath)
java.util.List<java.lang.String>
loadNodeViewersFile(java.io.File selectedFile)
void
removeWatchers(java.util.Collection<java.lang.String> selectedNodes)
void
saveDefaultConnectionFile(java.util.Properties props)
void
saveNodeViewersFile(java.io.File selectedFile, java.util.List<java.lang.String> nodeViewersClassNames)
boolean
setData(java.lang.String nodePath, java.lang.String data)
void
setDefaultNodeViewerConfiguration(java.util.List<java.lang.String> nodeViewersClassNames)
void
setLastConnectionProps(java.util.Properties connectionProps)
-
-
-
Field Detail
-
CONNECT_STRING
public static final java.lang.String CONNECT_STRING
The key used for the connect string in the connection properties file- See Also:
- Constant Field Values
-
SESSION_TIMEOUT
public static final java.lang.String SESSION_TIMEOUT
The key used for the session timeout in the connection properties file- See Also:
- Constant Field Values
-
DATA_ENCRYPTION_MANAGER
public static final java.lang.String DATA_ENCRYPTION_MANAGER
The key used for the data encryption manager in the connection properties file- See Also:
- Constant Field Values
-
AUTH_SCHEME_KEY
public static final java.lang.String AUTH_SCHEME_KEY
The key used for the authentication scheme in the connection properties file- See Also:
- Constant Field Values
-
AUTH_DATA_KEY
public static final java.lang.String AUTH_DATA_KEY
The key used for the authentication data in the connection properties file- See Also:
- Constant Field Values
-
connected
protected boolean connected
-
-
Method Detail
-
connect
public boolean connect(java.util.Properties connectionProps)
- Specified by:
connect
in interfaceZooInspectorManager
- Returns:
- true if successfully connected
-
disconnect
public boolean disconnect()
- Specified by:
disconnect
in interfaceZooInspectorManager
- Returns:
- true if successfully disconnected
-
getChildren
public java.util.List<java.lang.String> getChildren(java.lang.String nodePath)
- Specified by:
getChildren
in interfaceZooInspectorReadOnlyManager
- Parameters:
nodePath
- - the path to the node whose children to retrieve- Returns:
- a
List
of the children of the node
-
getData
public java.lang.String getData(java.lang.String nodePath)
- Specified by:
getData
in interfaceZooInspectorReadOnlyManager
- Parameters:
nodePath
- - the path to the node whose data is to be retrieved- Returns:
- the data for the node
-
getACLs
public java.util.List<java.util.Map<java.lang.String,java.lang.String>> getACLs(java.lang.String nodePath)
- Specified by:
getACLs
in interfaceZooInspectorReadOnlyManager
- Parameters:
nodePath
- - the path to the node whose ACLs are to be retrieved- Returns:
- the ACLs set on the node
-
getNodeMeta
public java.util.Map<java.lang.String,java.lang.String> getNodeMeta(java.lang.String nodePath)
- Specified by:
getNodeMeta
in interfaceZooInspectorReadOnlyManager
- Parameters:
nodePath
- - the path to the node whose metadata is to be retrieved- Returns:
- the metaData for the node
-
getNumChildren
public int getNumChildren(java.lang.String nodePath)
- Specified by:
getNumChildren
in interfaceZooInspectorReadOnlyManager
- Parameters:
nodePath
- - the path to the node to parent node- Returns:
- the number of children of the node
-
createNode
public boolean createNode(java.lang.String parent, java.lang.String nodeName)
- Specified by:
createNode
in interfaceZooInspectorNodeTreeManager
- Parameters:
parent
- - the parent node path for the node to addnodeName
- - the name of the new node- Returns:
- true if the node was successfully created
-
deleteNode
public boolean deleteNode(java.lang.String nodePath)
- Specified by:
deleteNode
in interfaceZooInspectorNodeTreeManager
- Parameters:
nodePath
- - the path to the node to delete- Returns:
- true if the node was successfully deleted
-
setData
public boolean setData(java.lang.String nodePath, java.lang.String data)
- Specified by:
setData
in interfaceZooInspectorNodeManager
- Parameters:
nodePath
- - the path to the node on which to set the datadata
- - the data to set on the this node- Returns:
- true if the data for the node was successfully updated
-
getConnectionPropertiesTemplate
public Pair<java.util.Map<java.lang.String,java.util.List<java.lang.String>>,java.util.Map<java.lang.String,java.lang.String>> getConnectionPropertiesTemplate()
- Specified by:
getConnectionPropertiesTemplate
in interfaceZooInspectorManager
- Returns:
- a
Pair
containing the following:- a
Map
of property keys to list of possible values. If the list size is 1 the value is taken to be the default value for aJTextField
. If the list size is greater than 1, the values are taken to be the possible options to show in aJComboBox
with the first selected as default. - a
Map
of property keys to the label to show on the UI
- a
-
addWatchers
public void addWatchers(java.util.Collection<java.lang.String> selectedNodes, NodeListener nodeListener)
- Specified by:
addWatchers
in interfaceZooInspectorManager
- Parameters:
selectedNodes
- - the nodes to add the watcher tonodeListener
- - the node listener for this watcher
-
removeWatchers
public void removeWatchers(java.util.Collection<java.lang.String> selectedNodes)
- Specified by:
removeWatchers
in interfaceZooInspectorManager
- Parameters:
selectedNodes
- - the nodes to remove the watchers from
-
loadNodeViewersFile
public java.util.List<java.lang.String> loadNodeViewersFile(java.io.File selectedFile) throws java.io.IOException
- Specified by:
loadNodeViewersFile
in interfaceZooInspectorManager
- Parameters:
selectedFile
- - the file to load which contains the node viewers configuration- Returns:
- nodeViewers - the class names of the node viewers from the configuration
- Throws:
java.io.IOException
- - if the configuration file cannot be loaded
-
saveDefaultConnectionFile
public void saveDefaultConnectionFile(java.util.Properties props) throws java.io.IOException
- Specified by:
saveDefaultConnectionFile
in interfaceZooInspectorManager
- Parameters:
props
- - the properties to use as the default connection settings- Throws:
java.io.IOException
- - if the default configuration file cannot be saved
-
saveNodeViewersFile
public void saveNodeViewersFile(java.io.File selectedFile, java.util.List<java.lang.String> nodeViewersClassNames) throws java.io.IOException
- Specified by:
saveNodeViewersFile
in interfaceZooInspectorManager
- Parameters:
selectedFile
- - the file to save the configuration tonodeViewersClassNames
- - the class names of the node viewers- Throws:
java.io.IOException
- - if the configuration file cannot be saved
-
setDefaultNodeViewerConfiguration
public void setDefaultNodeViewerConfiguration(java.util.List<java.lang.String> nodeViewersClassNames) throws java.io.IOException
- Specified by:
setDefaultNodeViewerConfiguration
in interfaceZooInspectorManager
- Parameters:
nodeViewersClassNames
- - the class names of the node viewers- Throws:
java.io.IOException
- - if the default configuration file cannot be loaded
-
getDefaultNodeViewerConfiguration
public java.util.List<java.lang.String> getDefaultNodeViewerConfiguration() throws java.io.IOException
- Specified by:
getDefaultNodeViewerConfiguration
in interfaceZooInspectorManager
- Returns:
- nodeViewers - the class names of the node viewers from the configuration
- Throws:
java.io.IOException
- - if the default configuration file cannot be loaded
-
getLastConnectionProps
public java.util.Properties getLastConnectionProps()
- Specified by:
getLastConnectionProps
in interfaceZooInspectorManager
- Returns:
- last connection Properties - the connection properties last used to connect to the zookeeeper instance
-
setLastConnectionProps
public void setLastConnectionProps(java.util.Properties connectionProps)
- Specified by:
setLastConnectionProps
in interfaceZooInspectorManager
- Parameters:
connectionProps
- - the connection properties last used to connect to the zookeeeper instance
-
-