org.apache.catalina.tribes.tipis.LazyReplicatedMap Java Examples

The following examples show how to use org.apache.catalina.tribes.tipis.LazyReplicatedMap. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: BackupManager.java    From Tomcat8-Source-Read with MIT License 6 votes vote down vote up
/**
 * Start this component and implement the requirements
 * of {@link org.apache.catalina.util.LifecycleBase#startInternal()}.
 *
 * Starts the cluster communication channel, this will connect with the
 * other nodes in the cluster, and request the current session state to be
 * transferred to this node.
 *
 * @exception LifecycleException if this component detects a fatal error
 *  that prevents this component from being used
 */
@Override
protected synchronized void startInternal() throws LifecycleException {

    super.startInternal();

    try {
        if (cluster == null) throw new LifecycleException(sm.getString("backupManager.noCluster", getName()));
        LazyReplicatedMap<String,Session> map = new LazyReplicatedMap<>(
                this, cluster.getChannel(), rpcTimeout, getMapName(),
                getClassLoaders(), terminateOnStartFailure);
        map.setChannelSendOptions(mapSendOptions);
        map.setAccessTimeout(accessTimeout);
        this.sessions = map;
    }  catch ( Exception x ) {
        log.error(sm.getString("backupManager.startUnable", getName()),x);
        throw new LifecycleException(sm.getString("backupManager.startFailed", getName()),x);
    }
    setState(LifecycleState.STARTING);
}
 
Example #2
Source File: MapDemo.java    From tomcatsrc with Apache License 2.0 6 votes vote down vote up
/**
 * Create the GUI and show it.  For thread safety,
 * this method should be invoked from the
 * event-dispatching thread.
 */
public static SimpleTableDemo createAndShowGUI(
        LazyReplicatedMap<String,StringBuilder> map, String title) {
    //Make sure we have nice window decorations.
    JFrame.setDefaultLookAndFeelDecorated(true);

    //Create and set up the window.
    JFrame frame = new JFrame("SimpleTableDemo - "+title);
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    //Create and set up the content pane.
    SimpleTableDemo newContentPane = new SimpleTableDemo(map);
    newContentPane.setOpaque(true); //content panes must be opaque
    frame.setContentPane(newContentPane);

    //Display the window.
    frame.setSize(450,250);
    newContentPane.setSize(450,300);
    frame.pack();
    frame.setVisible(true);
    return newContentPane;
}
 
Example #3
Source File: MapDemo.java    From tomcatsrc with Apache License 2.0 6 votes vote down vote up
@Override
public Object getValueAt(int row, int col) {
    if ( row==-1 ) {
        update();
        return "";
    }
    if ( row == 0 ) return columnNames[col];
    Object[] keys = map.keySetFull().toArray();
    String key = (String)keys [row-1];
    LazyReplicatedMap.MapEntry<String,StringBuilder> entry =
            map.getInternal(key);
    switch (col) {
        case 0: return String.valueOf(row);
        case 1: return entry.getKey();
        case 2: return entry.getValue();
        case 3: return entry.getPrimary()!=null?entry.getPrimary().getName():"null";
        case 4: return getMemberNames(entry.getBackupNodes());
        case 5: return Boolean.valueOf(entry.isPrimary());
        case 6: return Boolean.valueOf(entry.isProxy());
        case 7: return Boolean.valueOf(entry.isBackup());
        default: return "";
    }

}
 
Example #4
Source File: BackupManager.java    From tomcatsrc with Apache License 2.0 6 votes vote down vote up
/**
 * Stop this component and implement the requirements
 * of {@link org.apache.catalina.util.LifecycleBase#stopInternal()}.
 *
 * This will disconnect the cluster communication channel and stop the
 * listener thread.
 *
 * @exception LifecycleException if this component detects a fatal error
 *  that prevents this component from being used
 */
@Override
protected synchronized void stopInternal() throws LifecycleException {

    if (log.isDebugEnabled())
        log.debug(sm.getString("backupManager.stopped", getName()));

    setState(LifecycleState.STOPPING);

    if (sessions instanceof LazyReplicatedMap) {
        LazyReplicatedMap<String,Session> map =
                (LazyReplicatedMap<String,Session>)sessions;
        map.breakdown();
    }

    super.stopInternal();
}
 
Example #5
Source File: BackupManager.java    From tomcatsrc with Apache License 2.0 6 votes vote down vote up
/**
 * Start this component and implement the requirements
 * of {@link org.apache.catalina.util.LifecycleBase#startInternal()}.
 *
 * Starts the cluster communication channel, this will connect with the
 * other nodes in the cluster, and request the current session state to be
 * transferred to this node.
 *
 * @exception LifecycleException if this component detects a fatal error
 *  that prevents this component from being used
 */
@Override
protected synchronized void startInternal() throws LifecycleException {

    super.startInternal();

    try {
        if (cluster == null) throw new LifecycleException(sm.getString("backupManager.noCluster", getName()));
        LazyReplicatedMap<String,Session> map =
                new LazyReplicatedMap<String,Session>(this,
                        cluster.getChannel(), rpcTimeout, getMapName(),
                        getClassLoaders(), terminateOnStartFailure);
        map.setChannelSendOptions(mapSendOptions);
        this.sessions = map;
    }  catch ( Exception x ) {
        log.error(sm.getString("backupManager.startUnable", getName()),x);
        throw new LifecycleException(sm.getString("backupManager.startFailed", getName()),x);
    }
    setState(LifecycleState.STARTING);
}
 
Example #6
Source File: MapDemo.java    From Tomcat7.0.67 with Apache License 2.0 6 votes vote down vote up
/**
 * Create the GUI and show it.  For thread safety,
 * this method should be invoked from the
 * event-dispatching thread.
 */
public static SimpleTableDemo createAndShowGUI(
        LazyReplicatedMap<String,StringBuilder> map, String title) {
    //Make sure we have nice window decorations.
    JFrame.setDefaultLookAndFeelDecorated(true);

    //Create and set up the window.
    JFrame frame = new JFrame("SimpleTableDemo - "+title);
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    //Create and set up the content pane.
    SimpleTableDemo newContentPane = new SimpleTableDemo(map);
    newContentPane.setOpaque(true); //content panes must be opaque
    frame.setContentPane(newContentPane);

    //Display the window.
    frame.setSize(450,250);
    newContentPane.setSize(450,300);
    frame.pack();
    frame.setVisible(true);
    return newContentPane;
}
 
Example #7
Source File: MapDemo.java    From Tomcat7.0.67 with Apache License 2.0 6 votes vote down vote up
@Override
public Object getValueAt(int row, int col) {
    if ( row==-1 ) {
        update();
        return "";
    }
    if ( row == 0 ) return columnNames[col];
    Object[] keys = map.keySetFull().toArray();
    String key = (String)keys [row-1];
    LazyReplicatedMap.MapEntry<String,StringBuilder> entry =
            map.getInternal(key);
    switch (col) {
        case 0: return String.valueOf(row);
        case 1: return entry.getKey();
        case 2: return entry.getValue();
        case 3: return entry.getPrimary()!=null?entry.getPrimary().getName():"null";
        case 4: return getMemberNames(entry.getBackupNodes());
        case 5: return Boolean.valueOf(entry.isPrimary());
        case 6: return Boolean.valueOf(entry.isProxy());
        case 7: return Boolean.valueOf(entry.isBackup());
        default: return "";
    }

}
 
Example #8
Source File: BackupManager.java    From Tomcat7.0.67 with Apache License 2.0 6 votes vote down vote up
/**
 * Stop this component and implement the requirements
 * of {@link org.apache.catalina.util.LifecycleBase#stopInternal()}.
 *
 * This will disconnect the cluster communication channel and stop the
 * listener thread.
 *
 * @exception LifecycleException if this component detects a fatal error
 *  that prevents this component from being used
 */
@Override
protected synchronized void stopInternal() throws LifecycleException {

    if (log.isDebugEnabled())
        log.debug(sm.getString("backupManager.stopped", getName()));

    setState(LifecycleState.STOPPING);

    if (sessions instanceof LazyReplicatedMap) {
        LazyReplicatedMap<String,Session> map =
                (LazyReplicatedMap<String,Session>)sessions;
        map.breakdown();
    }

    super.stopInternal();
}
 
Example #9
Source File: BackupManager.java    From Tomcat7.0.67 with Apache License 2.0 6 votes vote down vote up
/**
 * Start this component and implement the requirements
 * of {@link org.apache.catalina.util.LifecycleBase#startInternal()}.
 *
 * Starts the cluster communication channel, this will connect with the
 * other nodes in the cluster, and request the current session state to be
 * transferred to this node.
 *
 * @exception LifecycleException if this component detects a fatal error
 *  that prevents this component from being used
 */
@Override
protected synchronized void startInternal() throws LifecycleException {

    super.startInternal();

    try {
        if (cluster == null) throw new LifecycleException(sm.getString("backupManager.noCluster", getName()));
        LazyReplicatedMap<String,Session> map =
                new LazyReplicatedMap<String,Session>(this,
                        cluster.getChannel(), rpcTimeout, getMapName(),
                        getClassLoaders(), terminateOnStartFailure);
        map.setChannelSendOptions(mapSendOptions);
        this.sessions = map;
    }  catch ( Exception x ) {
        log.error(sm.getString("backupManager.startUnable", getName()),x);
        throw new LifecycleException(sm.getString("backupManager.startFailed", getName()),x);
    }
    setState(LifecycleState.STARTING);
}
 
Example #10
Source File: MapDemo.java    From Tomcat8-Source-Read with MIT License 6 votes vote down vote up
public static SimpleTableDemo createAndShowGUI(
        LazyReplicatedMap<String,StringBuilder> map, String title) {
    //Make sure we have nice window decorations.
    JFrame.setDefaultLookAndFeelDecorated(true);

    //Create and set up the window.
    JFrame frame = new JFrame("SimpleTableDemo - "+title);
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    //Create and set up the content pane.
    SimpleTableDemo newContentPane = new SimpleTableDemo(map);
    newContentPane.setOpaque(true); //content panes must be opaque
    frame.setContentPane(newContentPane);

    //Display the window.
    frame.setSize(450,250);
    newContentPane.setSize(450,300);
    frame.pack();
    frame.setVisible(true);
    return newContentPane;
}
 
Example #11
Source File: BackupManager.java    From Tomcat8-Source-Read with MIT License 6 votes vote down vote up
/**
 * Stop this component and implement the requirements
 * of {@link org.apache.catalina.util.LifecycleBase#stopInternal()}.
 *
 * This will disconnect the cluster communication channel and stop the
 * listener thread.
 *
 * @exception LifecycleException if this component detects a fatal error
 *  that prevents this component from being used
 */
@Override
protected synchronized void stopInternal() throws LifecycleException {

    if (log.isDebugEnabled())
        log.debug(sm.getString("backupManager.stopped", getName()));

    setState(LifecycleState.STOPPING);

    if (sessions instanceof LazyReplicatedMap) {
        LazyReplicatedMap<String,Session> map =
                (LazyReplicatedMap<String,Session>)sessions;
        map.breakdown();
    }

    super.stopInternal();
}
 
Example #12
Source File: MapDemo.java    From Tomcat8-Source-Read with MIT License 6 votes vote down vote up
@Override
public Object getValueAt(int row, int col) {
    if ( row==-1 ) {
        update();
        return "";
    }
    if ( row == 0 ) return columnNames[col];
    Object[] keys = map.keySetFull().toArray();
    String key = (String)keys [row-1];
    LazyReplicatedMap.MapEntry<String,StringBuilder> entry =
            map.getInternal(key);
    switch (col) {
        case 0: return String.valueOf(row);
        case 1: return entry.getKey();
        case 2: return entry.getValue();
        case 3: return entry.getPrimary()!=null?entry.getPrimary().getName():"null";
        case 4: return getMemberNames(entry.getBackupNodes());
        case 5: return Boolean.valueOf(entry.isPrimary());
        case 6: return Boolean.valueOf(entry.isProxy());
        case 7: return Boolean.valueOf(entry.isBackup());
        default: return "";
    }

}
 
Example #13
Source File: BackupManager.java    From Tomcat8-Source-Read with MIT License 5 votes vote down vote up
@Override
public ClusterMessage requestCompleted(String sessionId) {
    if (!getState().isAvailable()) return null;
    LazyReplicatedMap<String,Session> map =
            (LazyReplicatedMap<String,Session>)sessions;
    map.replicate(sessionId,false);
    return null;
}
 
Example #14
Source File: BackupManager.java    From Tomcat7.0.67 with Apache License 2.0 5 votes vote down vote up
@Override
public ClusterMessage requestCompleted(String sessionId) {
    if (!getState().isAvailable()) return null;
    LazyReplicatedMap<String,Session> map =
            (LazyReplicatedMap<String,Session>)sessions;
    map.replicate(sessionId,false);
    return null;
}
 
Example #15
Source File: MapDemo.java    From tomcatsrc with Apache License 2.0 5 votes vote down vote up
/**
 * Constructs a map demo object.
 * @param channel - the Tribes channel object to be used for communication
 * @param mapName - the name of this map
 */
public MapDemo(Channel channel, String mapName ) {
    //instantiate the replicated map
    map = new LazyReplicatedMap<String,StringBuilder>(null, channel, 5000,
            mapName, null);
    //create a gui, name it with the member name of this JVM
    table = SimpleTableDemo.createAndShowGUI(map,channel.getLocalMember(false).getName());
    //add ourself as a listener for messages
    channel.addChannelListener(this);
    //add ourself as a listener for memberships
    channel.addMembershipListener(this);
    //initialize the map by receiving a fake message
    this.messageReceived(null,null);
}
 
Example #16
Source File: BackupManager.java    From tomcatsrc with Apache License 2.0 5 votes vote down vote up
@Override
public Set<String> getSessionIdsFull() {
    Set<String> sessionIds = new HashSet<String>();
    LazyReplicatedMap<String,Session> map =
            (LazyReplicatedMap<String,Session>)sessions;
    Iterator<String> keys = map.keySetFull().iterator();
    while (keys.hasNext()) {
        sessionIds.add(keys.next());
    }
    return sessionIds;
}
 
Example #17
Source File: BackupManager.java    From Tomcat8-Source-Read with MIT License 5 votes vote down vote up
@Override
public Set<String> getSessionIdsFull() {
    Set<String> sessionIds = new HashSet<>();
    LazyReplicatedMap<String,Session> map =
            (LazyReplicatedMap<String,Session>)sessions;
    for (String id : map.keySetFull()) {
        sessionIds.add(id);
    }
    return sessionIds;
}
 
Example #18
Source File: BackupManager.java    From tomcatsrc with Apache License 2.0 5 votes vote down vote up
@Override
public ClusterMessage requestCompleted(String sessionId) {
    if (!getState().isAvailable()) return null;
    LazyReplicatedMap<String,Session> map =
            (LazyReplicatedMap<String,Session>)sessions;
    map.replicate(sessionId,false);
    return null;
}
 
Example #19
Source File: MapDemo.java    From Tomcat8-Source-Read with MIT License 5 votes vote down vote up
/**
 * Constructs a map demo object.
 * @param channel - the Tribes channel object to be used for communication
 * @param mapName - the name of this map
 */
public MapDemo(Channel channel, String mapName ) {
    //instantiate the replicated map
    map = new LazyReplicatedMap<>(null, channel, 5000, mapName, null);
    //create a gui, name it with the member name of this JVM
    table = SimpleTableDemo.createAndShowGUI(map,channel.getLocalMember(false).getName());
    //add ourself as a listener for messages
    channel.addChannelListener(this);
    //add ourself as a listener for memberships
    channel.addMembershipListener(this);
    //initialize the map by receiving a fake message
    this.messageReceived(null,null);
}
 
Example #20
Source File: MapDemo.java    From Tomcat7.0.67 with Apache License 2.0 5 votes vote down vote up
/**
 * Constructs a map demo object.
 * @param channel - the Tribes channel object to be used for communication
 * @param mapName - the name of this map
 */
public MapDemo(Channel channel, String mapName ) {
    //instantiate the replicated map
    map = new LazyReplicatedMap<String,StringBuilder>(null, channel, 5000,
            mapName, null);
    //create a gui, name it with the member name of this JVM
    table = SimpleTableDemo.createAndShowGUI(map,channel.getLocalMember(false).getName());
    //add ourself as a listener for messages
    channel.addChannelListener(this);
    //add ourself as a listener for memberships
    channel.addMembershipListener(this);
    //initialize the map by receiving a fake message
    this.messageReceived(null,null);
}
 
Example #21
Source File: BackupManager.java    From Tomcat7.0.67 with Apache License 2.0 5 votes vote down vote up
@Override
public Set<String> getSessionIdsFull() {
    Set<String> sessionIds = new HashSet<String>();
    LazyReplicatedMap<String,Session> map =
            (LazyReplicatedMap<String,Session>)sessions;
    Iterator<String> keys = map.keySetFull().iterator();
    while (keys.hasNext()) {
        sessionIds.add(keys.next());
    }
    return sessionIds;
}
 
Example #22
Source File: MapDemo.java    From Tomcat7.0.67 with Apache License 2.0 4 votes vote down vote up
public SimpleTableDemo(LazyReplicatedMap<String,StringBuilder> map) {
    super();
    this.map = map;

    this.setComponentOrientation(ComponentOrientation.LEFT_TO_RIGHT);

    //final JTable table = new JTable(data, columnNames);
    table = new JTable(dataModel);

    table.setPreferredScrollableViewportSize(new Dimension(WIDTH, 150));
    for ( int i=0; i<table.getColumnCount(); i++ ) {
        TableColumn tm = table.getColumnModel().getColumn(i);
        tm.setCellRenderer(new ColorRenderer());
    }


    if (DEBUG) {
        table.addMouseListener(new MouseAdapter() {
            @Override
            public void mouseClicked(MouseEvent e) {
                printDebugData(table);
            }
        });
    }

    //setLayout(new GridLayout(5, 0));
    setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));

    //Create the scroll pane and add the table to it.
    JScrollPane scrollPane = new JScrollPane(table);

    //Add the scroll pane to this panel.
    add(scrollPane);

    //create a add value button
    JPanel addpanel = new JPanel();
    addpanel.setPreferredSize(new Dimension(WIDTH,30));
    addpanel.add(createButton("Add","add"));
    addpanel.add(txtAddKey);
    addpanel.add(txtAddValue);
    addpanel.setMaximumSize(new Dimension(WIDTH,30));
    add(addpanel);

    //create a remove value button
    JPanel removepanel = new JPanel( );
    removepanel.setPreferredSize(new Dimension(WIDTH,30));
    removepanel.add(createButton("Remove","remove"));
    removepanel.add(txtRemoveKey);
    removepanel.setMaximumSize(new Dimension(WIDTH,30));
    add(removepanel);

    //create a change value button
    JPanel changepanel = new JPanel( );
    changepanel.add(createButton("Change","change"));
    changepanel.add(txtChangeKey);
    changepanel.add(txtChangeValue);
    changepanel.setPreferredSize(new Dimension(WIDTH,30));
    changepanel.setMaximumSize(new Dimension(WIDTH,30));
    add(changepanel);


    //create sync button
    JPanel syncpanel = new JPanel( );
    syncpanel.add(createButton("Synchronize","sync"));
    syncpanel.add(createButton("Replicate","replicate"));
    syncpanel.add(createButton("Random","random"));
    syncpanel.setPreferredSize(new Dimension(WIDTH,30));
    syncpanel.setMaximumSize(new Dimension(WIDTH,30));
    add(syncpanel);


}
 
Example #23
Source File: BackupManager.java    From Tomcat8-Source-Read with MIT License 4 votes vote down vote up
@Override
public int getActiveSessionsFull() {
    LazyReplicatedMap<String,Session> map =
            (LazyReplicatedMap<String,Session>)sessions;
    return map.sizeFull();
}
 
Example #24
Source File: BackupManager.java    From tomcatsrc with Apache License 2.0 4 votes vote down vote up
@Override
public int getActiveSessionsFull() {
    LazyReplicatedMap<String,Session> map =
            (LazyReplicatedMap<String,Session>)sessions;
    return map.sizeFull();
}
 
Example #25
Source File: BackupManager.java    From Tomcat7.0.67 with Apache License 2.0 4 votes vote down vote up
@Override
public int getActiveSessionsFull() {
    LazyReplicatedMap<String,Session> map =
            (LazyReplicatedMap<String,Session>)sessions;
    return map.sizeFull();
}
 
Example #26
Source File: MapDemo.java    From tomcatsrc with Apache License 2.0 4 votes vote down vote up
public SimpleTableDemo(LazyReplicatedMap<String,StringBuilder> map) {
    super();
    this.map = map;

    this.setComponentOrientation(ComponentOrientation.LEFT_TO_RIGHT);

    //final JTable table = new JTable(data, columnNames);
    table = new JTable(dataModel);

    table.setPreferredScrollableViewportSize(new Dimension(WIDTH, 150));
    for ( int i=0; i<table.getColumnCount(); i++ ) {
        TableColumn tm = table.getColumnModel().getColumn(i);
        tm.setCellRenderer(new ColorRenderer());
    }


    if (DEBUG) {
        table.addMouseListener(new MouseAdapter() {
            @Override
            public void mouseClicked(MouseEvent e) {
                printDebugData(table);
            }
        });
    }

    //setLayout(new GridLayout(5, 0));
    setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));

    //Create the scroll pane and add the table to it.
    JScrollPane scrollPane = new JScrollPane(table);

    //Add the scroll pane to this panel.
    add(scrollPane);

    //create a add value button
    JPanel addpanel = new JPanel();
    addpanel.setPreferredSize(new Dimension(WIDTH,30));
    addpanel.add(createButton("Add","add"));
    addpanel.add(txtAddKey);
    addpanel.add(txtAddValue);
    addpanel.setMaximumSize(new Dimension(WIDTH,30));
    add(addpanel);

    //create a remove value button
    JPanel removepanel = new JPanel( );
    removepanel.setPreferredSize(new Dimension(WIDTH,30));
    removepanel.add(createButton("Remove","remove"));
    removepanel.add(txtRemoveKey);
    removepanel.setMaximumSize(new Dimension(WIDTH,30));
    add(removepanel);

    //create a change value button
    JPanel changepanel = new JPanel( );
    changepanel.add(createButton("Change","change"));
    changepanel.add(txtChangeKey);
    changepanel.add(txtChangeValue);
    changepanel.setPreferredSize(new Dimension(WIDTH,30));
    changepanel.setMaximumSize(new Dimension(WIDTH,30));
    add(changepanel);


    //create sync button
    JPanel syncpanel = new JPanel( );
    syncpanel.add(createButton("Synchronize","sync"));
    syncpanel.add(createButton("Replicate","replicate"));
    syncpanel.add(createButton("Random","random"));
    syncpanel.setPreferredSize(new Dimension(WIDTH,30));
    syncpanel.setMaximumSize(new Dimension(WIDTH,30));
    add(syncpanel);


}
 
Example #27
Source File: MapDemo.java    From Tomcat8-Source-Read with MIT License 4 votes vote down vote up
public SimpleTableDemo(LazyReplicatedMap<String,StringBuilder> map) {
    super();
    this.map = map;

    this.setComponentOrientation(ComponentOrientation.LEFT_TO_RIGHT);

    //final JTable table = new JTable(data, columnNames);
    table = new JTable(dataModel);

    table.setPreferredScrollableViewportSize(new Dimension(WIDTH, 150));
    for ( int i=0; i<table.getColumnCount(); i++ ) {
        TableColumn tm = table.getColumnModel().getColumn(i);
        tm.setCellRenderer(new ColorRenderer());
    }


    if (DEBUG) {
        table.addMouseListener(new MouseAdapter() {
            @Override
            public void mouseClicked(MouseEvent e) {
                printDebugData(table);
            }
        });
    }

    //setLayout(new GridLayout(5, 0));
    setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));

    //Create the scroll pane and add the table to it.
    JScrollPane scrollPane = new JScrollPane(table);

    //Add the scroll pane to this panel.
    add(scrollPane);

    //create a add value button
    JPanel addpanel = new JPanel();
    addpanel.setPreferredSize(new Dimension(WIDTH,30));
    addpanel.add(createButton("Add","add"));
    addpanel.add(txtAddKey);
    addpanel.add(txtAddValue);
    addpanel.setMaximumSize(new Dimension(WIDTH,30));
    add(addpanel);

    //create a remove value button
    JPanel removepanel = new JPanel( );
    removepanel.setPreferredSize(new Dimension(WIDTH,30));
    removepanel.add(createButton("Remove","remove"));
    removepanel.add(txtRemoveKey);
    removepanel.setMaximumSize(new Dimension(WIDTH,30));
    add(removepanel);

    //create a change value button
    JPanel changepanel = new JPanel( );
    changepanel.add(createButton("Change","change"));
    changepanel.add(txtChangeKey);
    changepanel.add(txtChangeValue);
    changepanel.setPreferredSize(new Dimension(WIDTH,30));
    changepanel.setMaximumSize(new Dimension(WIDTH,30));
    add(changepanel);


    //create sync button
    JPanel syncpanel = new JPanel( );
    syncpanel.add(createButton("Synchronize","sync"));
    syncpanel.add(createButton("Replicate","replicate"));
    syncpanel.add(createButton("Random","random"));
    syncpanel.setPreferredSize(new Dimension(WIDTH,30));
    syncpanel.setMaximumSize(new Dimension(WIDTH,30));
    add(syncpanel);


}