Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Polished

  • Loading branch information...
commit 3de2545b44b3109f3142d98dc436700e56120aad 1 parent f227dbe
Claus Ibsen davsclaus authored
3  fabric/fabric-core/src/main/scala/org/fusesource/fabric/api/data/ServiceInfo.java
View
@@ -18,8 +18,6 @@
/**
* Information about OSGi service.
- *
- * @author ldywicki
*/
public interface ServiceInfo {
@@ -53,7 +51,6 @@
Property[] getProperties();
-
interface Property {
String getKey();
Object getValue();
6 fabric/fabric-core/src/main/scala/org/fusesource/fabric/internal/Bundles.java
View
@@ -35,7 +35,7 @@ public static void startBundle(BundleContext context, String containsName) {
try {
bundle.start();
} catch (Exception e) {
- logger.error("Failed to start: " + e.getMessage(), e);
+ logger.warn("Failed to start bundle: " + name + " due " + e.getMessage() + ". This exception will be ignored.", e);
}
}
}
@@ -46,11 +46,11 @@ public static void stopBundle(BundleContext context, String containsName) {
for (Bundle bundle : bundles) {
String name = bundle.getSymbolicName();
if (name.contains(containsName)) {
- logger.debug("About to start bundle: " + name);
+ logger.debug("About to stop bundle: " + name);
try {
bundle.stop();
} catch (Exception e) {
- logger.error("Failed to start: " + e.getMessage(), e);
+ logger.warn("Failed to stop bundle: " + name + " due " + e.getMessage() + ". This exception will be ignored.", e);
}
}
}
9 fabric/fabric-core/src/main/scala/org/fusesource/fabric/internal/ContainerImpl.java
View
@@ -161,7 +161,8 @@ public void setProfiles(Profile[] profiles) {
String str = "";
for (Profile parent : profiles) {
if (!version.equals(parent.getVersion())) {
- throw new IllegalArgumentException("Bad profile: " + parent);
+ throw new IllegalArgumentException("Version mismatch setting profile " + parent + " with version "
+ + parent.getVersion() + " expected version " + version);
}
if (!str.isEmpty()) {
str += " ";
@@ -235,7 +236,7 @@ public ContainerTemplate getContainerTemplate() {
}
});
} catch (Exception e) {
- logger.error("Error while retrieving bundles", e);
+ logger.warn("Error while retrieving bundles. This exception will be ignored.", e);
return new BundleInfo[0];
}
}
@@ -259,7 +260,7 @@ public ContainerTemplate getContainerTemplate() {
}
});
} catch (Exception e) {
- logger.error("Error while retrieving services", e);
+ logger.warn("Error while retrieving services. This exception will be ignored.", e);
return new ServiceInfo[0];
}
}
@@ -270,7 +271,7 @@ public ContainerTemplate getContainerTemplate() {
Collections.sort(list);
return Collections.unmodifiableList(list);
} catch (Exception e) {
- logger.error("Error while retrieving jmx domains", e);
+ logger.warn("Error while retrieving jmx domains. This exception will be ignored.", e);
return Collections.emptyList();
}
}
3  fabric/fabric-core/src/main/scala/org/fusesource/fabric/internal/ProfileImpl.java
View
@@ -170,7 +170,8 @@ public void setParents(Profile[] parents) {
String str = "";
for (Profile parent : parents) {
if (!version.equals(parent.getVersion())) {
- throw new IllegalArgumentException("Bad profile: " + parent);
+ throw new IllegalArgumentException("Version mismatch setting parent profile " + parent + " with version "
+ + parent.getVersion() + " expected version " + version);
}
if (!str.isEmpty()) {
str += " ";
8 fabric/fabric-core/src/main/scala/org/fusesource/fabric/internal/ZooKeeperClusterServiceImpl.java
View
@@ -86,7 +86,7 @@ public void createLocalServer(int port) {
Configuration config = configurationAdmin.getConfiguration("org.fusesource.fabric.zookeeper");
Properties properties = new Properties();
String connectionUrl = getLocalHostAddress() + ":" + Integer.toString(port);
- String mavenProxyUrl = "http://"+getLocalHostAddress() + ":" + 8040;
+ String mavenProxyUrl = "http://" + getLocalHostAddress() + ":" + 8040;
properties.put("zookeeper.url", connectionUrl);
config.setBundleLocation(null);
config.update(properties);
@@ -129,7 +129,7 @@ public void createLocalServer(int port) {
p = getProperties(client, defaultProfile + "/org.fusesource.fabric.agent.properties", new Properties());
p.put("org.ops4j.pax.url.mvn.defaultRepositories", "file:${karaf.home}/${karaf.default.repository}@snapshots");
p.put("org.ops4j.pax.url.mvn.repositories", "http://repo1.maven.org/maven2,http://repo.fusesource.com/nexus/content/repositories/releases,http://scala-tools.org/repo-releases");
- p.put("repository.fabric", "mvn:org.fusesource.fabric/fuse-fabric/"+FabricConstants.VERSION+"/xml/features");
+ p.put("repository.fabric", "mvn:org.fusesource.fabric/fuse-fabric/" + FabricConstants.VERSION + "/xml/features");
p.put("feature.karaf", "karaf");
p.put("feature.fabric-agent", "fabric-agent");
p.put("feature.fabric-core", "fabric-core");
@@ -337,7 +337,7 @@ public void createCluster(List<String> containers) {
for (String container : containers) {
String ip = zooKeeper.getStringData(ZkPath.CONTAINER_IP.getPath(container));
String profNode = "/fabric/configs/versions/" + version + "/profiles/zk-server-" + newClusterId + "-" + Integer.toString(index);
- String pidNode = profNode + "/org.fusesource.fabric.zookeeper.server-" + newClusterId+".profile";
+ String pidNode = profNode + "/org.fusesource.fabric.zookeeper.server-" + newClusterId + ".profile";
Properties pidNodeProperties = new Properties();
ZooKeeperUtils.add(zooKeeper, profNode, "zk-server-" + newClusterId);
@@ -469,7 +469,7 @@ public void removeFromCluster(List<String> containers) {
current.removeAll(containers);
createCluster(current);
} catch (Exception e) {
- throw new FabricException("Unable to add containers to zookeeper quorum: " + e.getMessage(), e);
+ throw new FabricException("Unable to remove containers to zookeeper quorum: " + e.getMessage(), e);
}
}
24 fabric/fabric-core/src/main/scala/org/fusesource/fabric/internal/ZooKeeperUtils.java
View
@@ -30,7 +30,7 @@
public class ZooKeeperUtils {
- public static void copy( IZKClient source, IZKClient dest, String path ) throws InterruptedException, KeeperException {
+ public static void copy(IZKClient source, IZKClient dest, String path) throws InterruptedException, KeeperException {
for (String child : source.getChildren(path)) {
child = path + "/" + child;
if (dest.exists(child) == null) {
@@ -41,7 +41,7 @@ public static void copy( IZKClient source, IZKClient dest, String path ) throws
}
}
- public static void copy( IZKClient zk, String from, String to ) throws InterruptedException, KeeperException {
+ public static void copy(IZKClient zk, String from, String to) throws InterruptedException, KeeperException {
for (String child : zk.getChildren(from)) {
String fromChild = from + "/" + child;
String toChild = to + "/" + child;
@@ -53,11 +53,11 @@ public static void copy( IZKClient zk, String from, String to ) throws Interrupt
}
}
- public static void add( IZKClient zooKeeper, String path, String value ) throws InterruptedException, KeeperException {
+ public static void add(IZKClient zooKeeper, String path, String value) throws InterruptedException, KeeperException {
if (zooKeeper.exists(path) == null) {
zooKeeper.createOrSetWithParents(path, value, ZooDefs.Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT);
} else {
- String data = zooKeeper.getStringData( path );
+ String data = zooKeeper.getStringData(path);
if (data == null) {
data = "";
}
@@ -65,11 +65,11 @@ public static void add( IZKClient zooKeeper, String path, String value ) throws
data += " ";
}
data += value;
- zooKeeper.setData( path, data );
+ zooKeeper.setData(path, data);
}
}
- public static void remove( IZKClient zooKeeper, String path, String value ) throws InterruptedException, KeeperException {
+ public static void remove(IZKClient zooKeeper, String path, String value ) throws InterruptedException, KeeperException {
if (zooKeeper.exists(path) != null) {
String data = zooKeeper.getStringData( path );
List<String> parts = new ArrayList<String>(Arrays.asList(data.split(" ")));
@@ -89,24 +89,24 @@ public static void remove( IZKClient zooKeeper, String path, String value ) thro
}
data += part;
}
- zooKeeper.setData( path, data );
+ zooKeeper.setData(path, data);
}
}
}
- public static String get( IZKClient zooKeeper, String path ) throws InterruptedException, KeeperException {
- return zooKeeper.getStringData( path );
+ public static String get(IZKClient zooKeeper, String path) throws InterruptedException, KeeperException {
+ return zooKeeper.getStringData( path);
}
- public static void set( IZKClient zooKeeper, String path, String value ) throws InterruptedException, KeeperException {
+ public static void set(IZKClient zooKeeper, String path, String value) throws InterruptedException, KeeperException {
zooKeeper.createOrSetWithParents(path, value, ZooDefs.Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT);
}
- public static void create( IZKClient zooKeeper, String path ) throws InterruptedException, KeeperException {
+ public static void create(IZKClient zooKeeper, String path) throws InterruptedException, KeeperException {
zooKeeper.createWithParents(path, null, ZooDefs.Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT);
}
- public static void createDefault( IZKClient zooKeeper, String path, String value ) throws InterruptedException, KeeperException {
+ public static void createDefault(IZKClient zooKeeper, String path, String value) throws InterruptedException, KeeperException {
if (zooKeeper.exists(path) == null) {
zooKeeper.createWithParents( path, value, ZooDefs.Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT );
}
36 fabric/fabric-core/src/main/scala/org/fusesource/fabric/service/ChildContainerProvider.java
View
@@ -31,18 +31,7 @@ public ChildContainerProvider(FabricServiceImpl service) {
this.service = service;
}
- /**
- * Creates an {@link org.fusesource.fabric.api.Container} with the given name pointing to the specified zooKeeperUrl.
- *
- * @param proxyUri
- * @param containerUri The uri that contains required information to build the Container.
- * @param name The name of the Container.
- * @param zooKeeperUrl The url of Zoo Keeper.
- * @param debugContainer Flag used to enable debugging on the new Container.
- * @param number The number of Containers to create.
- * @param isEnsembleServer Marks if the agent will have the role of the cluster server.
- * @param debugContainer
- */
+ @Override
public void create(URI proxyUri, final URI containerUri, final String name, final String zooKeeperUrl, final boolean isEnsembleServer, final boolean debugContainer, final int number) {
String parentName = FabricServiceImpl.getParentFromURI(containerUri);
final Container parent = service.getContainer(parentName);
@@ -59,14 +48,14 @@ public void create(URI proxyUri, final URI containerUri, final String name, fina
containerTemplate.execute(new ContainerTemplate.AdminServiceCallback<Object>() {
public Object doWithAdminService(AdminServiceMBean adminService) throws Exception {
String javaOpts = zooKeeperUrl != null ? "-Dzookeeper.url=\"" + zooKeeperUrl + "\" -Xmx512M -server" : "";
- if(debugContainer) {
+ if (debugContainer) {
javaOpts += DEBUG_CONTAINER;
}
- if(isEnsembleServer) {
+ if (isEnsembleServer) {
javaOpts += ENSEMBLE_SERVER_CONTAINER;
}
String features = "fabric-agent";
- String featuresUrls = "mvn:org.fusesource.fabric/fuse-fabric/"+ FabricConstants.VERSION+"/xml/features";
+ String featuresUrls = "mvn:org.fusesource.fabric/fuse-fabric/" + FabricConstants.VERSION + "/xml/features";
for (int i = 1; i <= number; i++) {
String containerName = name;
@@ -81,28 +70,11 @@ public Object doWithAdminService(AdminServiceMBean adminService) throws Exceptio
});
}
- /**
- * Creates an {@link org.fusesource.fabric.api.Container} with the given name pointing to the specified zooKeeperUrl.
- *
- * @param proxyUri
- * @param containerUri The uri that contains required information to build the Container.
- * @param name The name of the Container.
- * @param zooKeeperUrl The url of Zoo Keeper.
- * @param debugContainer Flag used to enable debugging on the new Container.
- */
@Override
public void create(URI proxyUri, URI containerUri, String name, String zooKeeperUrl, boolean isEnsembleServer, boolean debugContainer) {
create(proxyUri, containerUri, name, zooKeeperUrl, isEnsembleServer, debugContainer,1);
}
- /**
- * Creates an {@link org.fusesource.fabric.api.Container} with the given name pointing to the specified zooKeeperUrl.
- *
- * @param proxyUri
- * @param containerUri The uri that contains required information to build the Container.
- * @param name The name of the Container.
- * @param zooKeeperUrl The url of Zoo Keeper.
- */
@Override
public void create(URI proxyUri, URI containerUri, String name, String zooKeeperUrl) {
create(proxyUri, containerUri, name, zooKeeperUrl,false, false);
14 fabric/fabric-core/src/main/scala/org/fusesource/fabric/service/FabricServiceImpl.java
View
@@ -161,7 +161,7 @@ private String getParentOf(String name) throws InterruptedException, KeeperExcep
} catch (KeeperException.NoNodeException e) {
// Ignore
} catch (Throwable e) {
- logger.warn("Failed to find parent " + name + ". Reason: " + e);
+ logger.warn("Failed to find parent " + name + ". This exception will be ignored.", e);
}
}
return "";
@@ -187,7 +187,7 @@ public Container getContainer(String name) {
public void startContainer(final Container container) {
if (container.isRoot()) {
- throw new IllegalArgumentException("Can not stop root containers");
+ throw new IllegalArgumentException("Cannot start root containers");
}
getContainerTemplate(container.getParent()).execute(new ContainerTemplate.AdminServiceCallback<Object>() {
public Object doWithAdminService(AdminServiceMBean adminService) throws Exception {
@@ -199,7 +199,7 @@ public Object doWithAdminService(AdminServiceMBean adminService) throws Exceptio
public void stopContainer(final Container container) {
if (container.isRoot()) {
- throw new IllegalArgumentException("Can not stop root containers");
+ throw new IllegalArgumentException("Cannot stop root containers");
}
getContainerTemplate(container.getParent()).execute(new ContainerTemplate.AdminServiceCallback<Object>() {
public Object doWithAdminService(AdminServiceMBean adminService) throws Exception {
@@ -402,7 +402,7 @@ public void registerMBeanServer(MBeanServer mbeanServer) {
ObjectName name = getMbeanName();
ObjectInstance objectInstance = mbeanServer.registerMBean(this, name);
} catch (Exception e) {
- logger.warn("An error occured during mbean server registration: " + e, e);
+ logger.warn("An error occurred during mbean server registration. This exception will be ignored.", e);
}
}
@@ -411,7 +411,7 @@ public void unregisterMBeanServer(MBeanServer mbeanServer) {
try {
mbeanServer.unregisterMBean(getMbeanName());
} catch (Exception e) {
- logger.warn("An error occured during mbean server registration: " + e, e);
+ logger.warn("An error occurred during mbean server un-registration. This exception will be ignored.", e);
}
}
}
@@ -422,11 +422,11 @@ public Container createContainer(final Container parent, final String name, fina
return getContainerTemplate(parent).execute(new ContainerTemplate.AdminServiceCallback<Container>() {
public Container doWithAdminService(AdminServiceMBean adminService) throws Exception {
String javaOpts = zooKeeperUrl != null ? "-Dzookeeper.url=\"" + zooKeeperUrl + "\" -Xmx512M -server" : "";
- if(debugContainer) {
+ if (debugContainer) {
javaOpts += ContainerProvider.DEBUG_CONTAINER;
}
String features = "fabric-agent";
- String featuresUrls = "mvn:org.fusesource.fabric/fuse-fabric/"+ FabricConstants.VERSION+"/xml/features";
+ String featuresUrls = "mvn:org.fusesource.fabric/fuse-fabric/" + FabricConstants.VERSION + "/xml/features";
adminService.createInstance(name, 0, 0, 0, null, javaOpts, features, featuresUrls);
adminService.startInstance(name, null);
return new ContainerImpl(parent, name, FabricServiceImpl.this);
Please sign in to comment.
Something went wrong with that request. Please try again.