Skip to content

Commit

Permalink
Mainly making management controllers to block on the storage manager
Browse files Browse the repository at this point in the history
  • Loading branch information
clebertsuconic committed Dec 3, 2009
1 parent ef16dc7 commit 2d14d92
Show file tree
Hide file tree
Showing 19 changed files with 1,767 additions and 418 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,20 @@ public void waitCompletion() throws Exception
{
throw new HornetQException(errorCode, errorMessage);
}

return;
}

public boolean waitCompletion(final long timeout) throws Exception
{
return latch.await(timeout, TimeUnit.MILLISECONDS);
boolean retValue = latch.await(timeout, TimeUnit.MILLISECONDS);

if (errorMessage != null)
{
throw new HornetQException(errorCode, errorMessage);
}

return retValue;
}

/* (non-Javadoc)
Expand Down
84 changes: 84 additions & 0 deletions src/main/org/hornetq/core/management/impl/AbstractControl.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
/*
* Copyright 2009 Red Hat, Inc.
* Red Hat licenses this file to you under the Apache License, version
* 2.0 (the "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
* implied. See the License for the specific language governing
* permissions and limitations under the License.
*/

package org.hornetq.core.management.impl;

import javax.management.NotCompliantMBeanException;
import javax.management.StandardMBean;

import org.hornetq.core.persistence.StorageManager;

/**
* A AbstractControl
*
* @author <mailto:clebert.suconic@jboss.org">Clebert Suconic</a>
*
*
*/
public abstract class AbstractControl extends StandardMBean
{

// Constants -----------------------------------------------------

// Attributes ----------------------------------------------------

protected final StorageManager storageManager;

// Static --------------------------------------------------------

// Constructors --------------------------------------------------

public AbstractControl(Class<?> clazz, StorageManager storageManager) throws NotCompliantMBeanException
{
super(clazz);
this.storageManager = storageManager;
}

// Public --------------------------------------------------------

// Package protected ---------------------------------------------

// Protected -----------------------------------------------------

protected void clearIO()
{
// the storage manager could be null on the backup on certain components
if (storageManager != null)
{
storageManager.clearContext();
}
}

protected void blockOnIO()
{
// the storage manager could be null on the backup on certain components
if (storageManager != null)
{
try
{
storageManager.waitOnOperations();
storageManager.clearContext();
}
catch (Exception e)
{
throw new RuntimeException(e.getMessage(), e);
}
}

}

// Private -------------------------------------------------------

// Inner classes -------------------------------------------------

}
72 changes: 61 additions & 11 deletions src/main/org/hornetq/core/management/impl/AcceptorControlImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

import org.hornetq.core.config.TransportConfiguration;
import org.hornetq.core.management.AcceptorControl;
import org.hornetq.core.persistence.StorageManager;
import org.hornetq.core.remoting.spi.Acceptor;

/**
Expand All @@ -28,7 +29,7 @@
*
* Created 11 dec. 2008 17:09:04
*/
public class AcceptorControlImpl extends StandardMBean implements AcceptorControl
public class AcceptorControlImpl extends AbstractControl implements AcceptorControl
{

// Constants -----------------------------------------------------
Expand All @@ -43,10 +44,11 @@ public class AcceptorControlImpl extends StandardMBean implements AcceptorContro

// Constructors --------------------------------------------------

public AcceptorControlImpl(final Acceptor acceptor, final TransportConfiguration configuration)
throws Exception
public AcceptorControlImpl(final Acceptor acceptor,
final StorageManager storageManager,
final TransportConfiguration configuration) throws Exception
{
super(AcceptorControl.class);
super(AcceptorControl.class, storageManager);
this.acceptor = acceptor;
this.configuration = configuration;
}
Expand All @@ -55,32 +57,80 @@ public AcceptorControlImpl(final Acceptor acceptor, final TransportConfiguration

public String getFactoryClassName()
{
return configuration.getFactoryClassName();
clearIO();
try
{
return configuration.getFactoryClassName();
}
finally
{
blockOnIO();
}
}

public String getName()
{
return configuration.getName();
clearIO();
try
{
return configuration.getName();
}
finally
{
blockOnIO();
}
}

public Map<String, Object> getParameters()
{
return configuration.getParams();
clearIO();
try
{
return configuration.getParams();
}
finally
{
blockOnIO();
}
}

public boolean isStarted()
{
return acceptor.isStarted();
clearIO();
try
{
return acceptor.isStarted();
}
finally
{
blockOnIO();
}
}

public void start() throws Exception
{
acceptor.start();
clearIO();
try
{
acceptor.start();
}
finally
{
blockOnIO();
}
}

public void stop() throws Exception
{
acceptor.stop();
clearIO();
try
{
acceptor.stop();
}
finally
{
blockOnIO();
}
}

// Public --------------------------------------------------------
Expand Down
Loading

0 comments on commit 2d14d92

Please sign in to comment.