Skip to content

Commit

Permalink
Merge pull request #175 from fogbow/develop
Browse files Browse the repository at this point in the history
Integrated with green sitter
  • Loading branch information
abmargb committed Mar 31, 2015
2 parents 8daaeca + 771ee46 commit 0f9a8bb
Show file tree
Hide file tree
Showing 85 changed files with 3,821 additions and 804 deletions.
20 changes: 20 additions & 0 deletions manager.conf.example
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ xmpp_host=127.0.0.1
xmpp_port=5347

rendezvous_jid=rendezvous.test.com
greensitter_jid=greensitter.test.com

compute_class=org.fogbowcloud.manager.core.plugins.opennebula.OpenNebulaComputePlugin
compute_one_url=http://localhost:2633/RPC2
Expand Down Expand Up @@ -37,12 +38,24 @@ compute_occi_instance_scheme=http://schemas.openstack.org/compute/instance#
compute_occi_resource_scheme=http://schemas.openstack.org/template/resource#
compute_occi_network_id=ea51ed0c-0e8a-448d-8202-c79777109ffe

# If you are using the EgiImageStoragePlugin
image_storage_class=org.fogbowcloud.manager.core.plugins.egi.EgiImageStoragePlugin
image_storage_egi_base_url=http://lsd.ufcg.edu.br/~user/vm/
image_storage_egi_tmp_storage=/tmp/

# If you are using the EgiApplianceImageStoragePlugin
image_storage_class=org.fogbowcloud.manager.core.plugins.appliance.EgiApplianceImageStoragePlugin
image_storage_appliance_base_url=http://appliance-repo.egi.eu/images
image_storage_appliance_tmp_storage=/tmp/

image_storage_static_fogbow-linux-x86=55d938ef-57d1-44ea-8155-6036d170780a
image_storage_static_fogbow-ubuntu-1204=81765250-a4e4-440d-a215-43c9c0849120

member_picker_class=org.fogbowcloud.manager.core.RoundRobinMemberPicker
#If you are using NoFMemberPicker class
nof_trustworthy=false


compute_class=org.fogbowcloud.manager.core.plugins.openstack.OpenStackNovaV2ComputePlugin
compute_novav2_url=http://localhost:8774
compute_glancev2_url=http://localhost:9292
Expand Down Expand Up @@ -72,6 +85,7 @@ token_update_period=300000
instance_monitoring_period=120000
served_request_monitoring_period=120000
garbage_collector_period=240000
asyn_request_waiting_interval=300000

ssh_tunnel_public_host=150.165.80.1
ssh_tunnel_private_host=10.0.0.1
Expand All @@ -83,3 +97,9 @@ my_ip=127.0.0.1
http_port=8182

max_whoisalive_manager_count=100

accounting_class=org.fogbowcloud.manager.core.plugins.accounting.FCUAccountingPlugin
accounting_update_period=300000
accounting_datastore_url=jdbc:h2:/tmp/usage

benchmarking_class=org.fogbowcloud.manager.core.plugins.benchmarking.FCUStaticBenchmarkingPlugin
6 changes: 6 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,12 @@
<artifactId>sshj</artifactId>
<version>0.8.1</version>
</dependency>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<version>1.4.186</version>
</dependency>

</dependencies>

</project>
86 changes: 72 additions & 14 deletions src/main/java/org/fogbowcloud/manager/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,18 @@
import org.apache.log4j.Logger;
import org.fogbowcloud.manager.core.ConfigurationConstants;
import org.fogbowcloud.manager.core.DefaultMemberValidator;
import org.fogbowcloud.manager.core.FederationMemberPicker;
import org.fogbowcloud.manager.core.FederationMemberValidator;
import org.fogbowcloud.manager.core.ManagerController;
import org.fogbowcloud.manager.core.RoundRobinMemberPicker;
import org.fogbowcloud.manager.core.plugins.AccountingPlugin;
import org.fogbowcloud.manager.core.plugins.AuthorizationPlugin;
import org.fogbowcloud.manager.core.plugins.BenchmarkingPlugin;
import org.fogbowcloud.manager.core.plugins.ComputePlugin;
import org.fogbowcloud.manager.core.plugins.IdentityPlugin;
import org.fogbowcloud.manager.core.plugins.ImageStoragePlugin;
import org.fogbowcloud.manager.core.plugins.accounting.FCUAccountingPlugin;
import org.fogbowcloud.manager.core.plugins.benchmarking.FCUStaticBenchmarkingPlugin;
import org.fogbowcloud.manager.core.plugins.egi.EgiImageStoragePlugin;
import org.fogbowcloud.manager.occi.OCCIApplication;
import org.fogbowcloud.manager.xmpp.ManagerXmppComponent;
Expand All @@ -25,21 +31,22 @@
public class Main {

private static final Logger LOGGER = Logger.getLogger(Main.class);

private static final int EXIT_ERROR_CODE = 128;

public static void main(String[] args) throws Exception {
configureLog4j();

Properties properties = new Properties();
FileInputStream input = new FileInputStream(args[0]);
properties.load(input);

ComputePlugin computePlugin;
ComputePlugin computePlugin = null;
try {
computePlugin = (ComputePlugin) createInstance(
ConfigurationConstants.COMPUTE_CLASS_KEY, properties);
} catch (Exception e) {
LOGGER.warn("Compute Plugin not especified in the properties.", e);
return;
System.exit(EXIT_ERROR_CODE);
}

AuthorizationPlugin authorizationPlugin = null;
Expand All @@ -48,7 +55,7 @@ public static void main(String[] args) throws Exception {
ConfigurationConstants.AUTHORIZATION_CLASS_KEY, properties);
} catch (Exception e) {
LOGGER.warn("Authorization Plugin not especified in the properties.", e);
return;
System.exit(EXIT_ERROR_CODE);
}

IdentityPlugin localIdentityPlugin = null;
Expand All @@ -57,7 +64,7 @@ public static void main(String[] args) throws Exception {
ConfigurationConstants.LOCAL_PREFIX);
} catch (Exception e) {
LOGGER.warn("Local Identity Plugin not especified in the properties.", e);
return;
System.exit(EXIT_ERROR_CODE);
}

IdentityPlugin federationIdentityPlugin = null;
Expand All @@ -66,15 +73,16 @@ public static void main(String[] args) throws Exception {
ConfigurationConstants.FEDERATION_PREFIX);
} catch (Exception e) {
LOGGER.warn("Federation Identity Plugin not especified in the properties.", e);
return;
System.exit(EXIT_ERROR_CODE);
}

FederationMemberValidator validator = new DefaultMemberValidator();
FederationMemberValidator validator = new DefaultMemberValidator(properties);
try {
validator = (FederationMemberValidator) createInstance(
ConfigurationConstants.MEMBER_VALIDATOR_KEY, properties);
} catch (Exception e) {
LOGGER.warn("Member Validator not especified in the properties.");
System.exit(EXIT_ERROR_CODE);
}

if (properties.get(ConfigurationConstants.RENDEZVOUS_JID_KEY) == null
Expand All @@ -91,6 +99,34 @@ public static void main(String[] args) throws Exception {
imageStoragePlugin = new EgiImageStoragePlugin(properties, computePlugin);
LOGGER.warn("Image Storage plugin not specified in properties. Using the default one.", e);
}

BenchmarkingPlugin benchmarkingPlugin = null;
try {
benchmarkingPlugin = (BenchmarkingPlugin) createInstance(
ConfigurationConstants.BENCHMARKING_PLUGIN_CLASS_KEY, properties);
} catch (Exception e) {
benchmarkingPlugin = new FCUStaticBenchmarkingPlugin(properties);
LOGGER.warn("Benchmarking plugin not specified in properties. Using the default one.", e);
}

AccountingPlugin accountingPlugin = null;
try {
accountingPlugin = (AccountingPlugin) createInstanceWithBenchmarkingPlugin(
ConfigurationConstants.ACCOUNTING_PLUGIN_CLASS_KEY, properties, benchmarkingPlugin);
} catch (Exception e) {
accountingPlugin = new FCUAccountingPlugin(properties, benchmarkingPlugin);
LOGGER.warn("Accounting plugin not specified in properties. Using the default one.", e);
}

FederationMemberPicker memberPickerPlugin = null;
try {
memberPickerPlugin = (FederationMemberPicker) createInstanceWithAccoutingPlugin(
ConfigurationConstants.MEMBER_PICKER_PLUGIN_CLASS_KEY, properties,
accountingPlugin);
} catch (Exception e) {
memberPickerPlugin = new RoundRobinMemberPicker(properties, accountingPlugin);
LOGGER.warn("Member picker plugin not specified in properties. Using the default one.", e);
}

ManagerController facade = new ManagerController(properties);
facade.setComputePlugin(computePlugin);
Expand All @@ -99,7 +135,10 @@ public static void main(String[] args) throws Exception {
facade.setFederationIdentityPlugin(federationIdentityPlugin);
facade.setImageStoragePlugin(imageStoragePlugin);
facade.setValidator(validator);

facade.setBenchmarkingPlugin(benchmarkingPlugin);
facade.setAccountingPlugin(accountingPlugin);
facade.setMemberPickerPlugin(memberPickerPlugin);

ManagerXmppComponent xmpp = new ManagerXmppComponent(
properties.getProperty(ConfigurationConstants.XMPP_JID_KEY),
properties.getProperty(ConfigurationConstants.XMPP_PASS_KEY),
Expand All @@ -111,7 +150,7 @@ public static void main(String[] args) throws Exception {
xmpp.connect();
} catch (ComponentException e) {
LOGGER.error("Conflict in the initialization of xmpp component.", e);
return;
System.exit(EXIT_ERROR_CODE);
}
xmpp.process(false);
xmpp.init();
Expand All @@ -122,11 +161,16 @@ public static void main(String[] args) throws Exception {
Slf4jLoggerFacade loggerFacade = new Slf4jLoggerFacade();
Engine.getInstance().setLoggerFacade(loggerFacade);

Component http = new Component();
http.getServers().add(Protocol.HTTP,
Integer.parseInt(properties.getProperty(ConfigurationConstants.HTTP_PORT_KEY)));
http.getDefaultHost().attach(application);
http.start();
try {
Component http = new Component();
http.getServers().add(Protocol.HTTP,
Integer.parseInt(properties.getProperty(ConfigurationConstants.HTTP_PORT_KEY)));
http.getDefaultHost().attach(application);
http.start();
} catch (Exception e) {
LOGGER.error("Conflict in the initialization of the HTTP component.", e);
System.exit(EXIT_ERROR_CODE);
}
}

private static Object getIdentityPluginByPrefix(Properties properties, String prefix)
Expand All @@ -153,6 +197,20 @@ private static Object createInstanceWithComputePlugin(String propName,
return Class.forName(properties.getProperty(propName)).getConstructor(Properties.class, ComputePlugin.class)
.newInstance(properties, computePlugin);
}

private static Object createInstanceWithBenchmarkingPlugin(
String propName, Properties properties,
BenchmarkingPlugin benchmarkingPlugin) throws Exception {
return Class.forName(properties.getProperty(propName)).getConstructor(Properties.class, BenchmarkingPlugin.class)
.newInstance(properties, benchmarkingPlugin);
}

private static Object createInstanceWithAccoutingPlugin(
String propName, Properties properties,
AccountingPlugin accoutingPlugin) throws Exception {
return Class.forName(properties.getProperty(propName)).getConstructor(Properties.class, AccountingPlugin.class)
.newInstance(properties, accoutingPlugin);
}

private static void configureLog4j() {
ConsoleAppender console = new ConsoleAppender();
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ public class ConfigurationConstants {
public static final String TOKEN_UPDATE_PERIOD_KEY = "token_update_period";
public static final String SERVED_REQUEST_MONITORING_PERIOD_KEY = "served_request_monitoring_period";
public static final String GARBAGE_COLLECTOR_PERIOD_KEY = "garbage_collector_period";
public static final String ACCOUNTING_UPDATE_PERIOD_KEY = "accounting_update_period";
public static final String ASYNC_REQUEST_WAITING_INTERVAL_KEY = "asyn_request_waiting_interval";

//ssh properties TODO change these properties names to TOKEN_HOST_...
public static final String SSH_PRIVATE_HOST_KEY = "ssh_tunnel_private_host";
Expand All @@ -46,6 +48,7 @@ public class ConfigurationConstants {
public static final String VOMS_PATH_VOMSES = "path_vomses";
public static final String VOMS_PATH_TRUST_ANCHORS = "path_trust_anchors";
public static final String VOMS_PATH_VOMSDIR = "path_vomsdir";
public static final String VOMS_SHOULD_FORWARD_PRIVATE_KEY = "should_forward_private_key";

//x509
public static final String X509_CA_DIR_PATH_KEY = "x509_ca_dir_path";
Expand All @@ -54,4 +57,15 @@ public class ConfigurationConstants {
public static final String MAX_WHOISALIVE_MANAGER_COUNT = "max_whoisalive_manager_count";
public static final String IMAGE_STORAGE_PLUGIN_CLASS = "image_storage_class";

//benchmarking
public static final String BENCHMARKING_PLUGIN_CLASS_KEY = "benchmarking_class";

//accounting
public static final String ACCOUNTING_PLUGIN_CLASS_KEY = "accounting_class";

//Green
public static final String GREEN_SITTER_JID = "greensitter_jid";

//member picker
public static final String MEMBER_PICKER_PLUGIN_CLASS_KEY = "member_picker_class";
}
Loading

0 comments on commit 0f9a8bb

Please sign in to comment.