-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
128 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,10 @@ | ||
package at.ac.tuwien.infosys.aic13.cloudscale.configuration; | ||
|
||
import java.io.IOException; | ||
import java.io.InputStream; | ||
import java.util.Properties; | ||
import java.util.logging.Level; | ||
|
||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
import at.ac.tuwien.infosys.aic13.cloudscale.events.TestEvent; | ||
import at.ac.tuwien.infosys.cloudscale.annotations.CloudScaleConfigurationProvider; | ||
import at.ac.tuwien.infosys.cloudscale.configuration.CloudScaleConfiguration; | ||
|
@@ -16,65 +16,77 @@ | |
* @author e0756024 <[email protected]> | ||
*/ | ||
public class ConfigurationProvider { | ||
|
||
@SuppressWarnings("unused") | ||
private static final Logger log = LoggerFactory.getLogger(ConfigurationProvider.class); | ||
|
||
@CloudScaleConfigurationProvider | ||
public static CloudScaleConfiguration getConfiguration() { | ||
// return localConfig(); | ||
return getEC2Config(); | ||
} | ||
|
||
/** | ||
* @return config for local testing | ||
*/ | ||
@SuppressWarnings("unused") | ||
private static CloudScaleConfiguration localConfig() { | ||
|
||
CloudScaleConfiguration cfg = new CloudScaleConfigurationBuilder() | ||
.withLogging(Level.WARNING) | ||
.with(new ScalingPolicyAlternative()) | ||
.withMonitoring(true) | ||
.withMonitoringEvents(TestEvent.class) | ||
.build(); | ||
|
||
//check every 60 seconds | ||
cfg.common().setScaleDownIntervalInSec(60); | ||
@CloudScaleConfigurationProvider | ||
public static CloudScaleConfiguration getConfiguration() { | ||
switch(getProperties().getProperty("g3p3.cloudScale.configurationProvider", "local")){ | ||
case "ec2": | ||
System.out.println("Using EC2-CloudScale Config (AHXIGO)."); | ||
return getEC2Config(); | ||
case "local": | ||
default: | ||
System.out.println("Using local CLoudScale Config (IT6Q81)."); | ||
return localConfig(); | ||
} | ||
} | ||
|
||
return cfg; | ||
private static Properties getProperties() { | ||
Properties properties = new Properties(); | ||
InputStream in = ConfigurationProvider.class.getClassLoader().getResourceAsStream( | ||
"aic13g3p3.properties"); | ||
try { | ||
properties.load(in); | ||
in.close(); | ||
} catch (IOException e) { | ||
System.err.println("Error while loading file 'aic13g3p3.properties' (025F2E). "+ e.getMessage()); | ||
} | ||
return properties; | ||
} | ||
|
||
} | ||
|
||
private static CloudScaleConfiguration getEC2Config() { | ||
|
||
final String AWS_CONFIG = "aws.properties"; | ||
final String AWS_ENDPOINT = "ec2.ap-southeast-1.amazonaws.com"; | ||
final String AWS_INSTANCE_TYPE = "t1.micro"; | ||
final String AWS_KEY = "awscs"; | ||
final String AWS_IMAGE_NAME = "CloudScale_v0.3.2 G3P3"; | ||
|
||
// CHANGE ME | ||
final String MQ_HOSTNAME = "ec2-54-251-13-247.ap-southeast-1.compute.amazonaws.com"; | ||
final int MQ_PORT = 61616; | ||
|
||
EC2CloudPlatformConfiguration ec2Config = new EC2CloudPlatformConfiguration(); | ||
ec2Config.setAwsConfigFile(ClassLoader.getSystemResource(AWS_CONFIG).getPath()); | ||
ec2Config.setAwsEndpoint(AWS_ENDPOINT); | ||
ec2Config.setInstanceType(AWS_INSTANCE_TYPE); | ||
ec2Config.setSshKey(AWS_KEY); | ||
ec2Config.setImageName(AWS_IMAGE_NAME); | ||
|
||
CloudScaleConfiguration config = new CloudScaleConfigurationBuilder() | ||
.with(ec2Config) | ||
.with(new ScalingPolicyAlternative()) | ||
.withMQServer(MQ_HOSTNAME, MQ_PORT) | ||
.withMonitoring(true) | ||
.withLogging(Level.OFF) | ||
.build(); | ||
|
||
config.common().setScaleDownIntervalInSec(20); | ||
|
||
return config; | ||
} | ||
/** | ||
* @return config for local testing | ||
*/ | ||
private static CloudScaleConfiguration localConfig() { | ||
|
||
CloudScaleConfiguration cfg = new CloudScaleConfigurationBuilder() | ||
.withLogging(Level.WARNING) | ||
.with(new ScalingPolicyAlternative()).withMonitoring(true) | ||
.withMonitoringEvents(TestEvent.class).build(); | ||
|
||
// check every 60 seconds | ||
cfg.common().setScaleDownIntervalInSec(60); | ||
|
||
return cfg; | ||
|
||
} | ||
|
||
private static CloudScaleConfiguration getEC2Config() { | ||
|
||
final String AWS_CONFIG = "aws.properties"; | ||
final String AWS_ENDPOINT = "ec2.ap-southeast-1.amazonaws.com"; | ||
final String AWS_INSTANCE_TYPE = "t1.micro"; | ||
final String AWS_KEY = "awscs"; | ||
final String AWS_IMAGE_NAME = "CloudScale_v0.3.2 G3P3"; | ||
|
||
// CHANGE ME | ||
final String MQ_HOSTNAME = "ec2-54-251-13-247.ap-southeast-1.compute.amazonaws.com"; | ||
final int MQ_PORT = 61616; | ||
|
||
EC2CloudPlatformConfiguration ec2Config = new EC2CloudPlatformConfiguration(); | ||
ec2Config.setAwsConfigFile(ClassLoader.getSystemResource(AWS_CONFIG) | ||
.getPath()); | ||
ec2Config.setAwsEndpoint(AWS_ENDPOINT); | ||
ec2Config.setInstanceType(AWS_INSTANCE_TYPE); | ||
ec2Config.setSshKey(AWS_KEY); | ||
ec2Config.setImageName(AWS_IMAGE_NAME); | ||
|
||
CloudScaleConfiguration config = new CloudScaleConfigurationBuilder() | ||
.with(ec2Config).with(new ScalingPolicyAlternative()) | ||
.withMQServer(MQ_HOSTNAME, MQ_PORT).withMonitoring(true) | ||
.withLogging(Level.OFF).build(); | ||
|
||
config.common().setScaleDownIntervalInSec(20); | ||
|
||
return config; | ||
} | ||
} |
43 changes: 43 additions & 0 deletions
43
src/main/java/at/ac/tuwien/infosys/aic13/sentiment/WEKAFileProvider.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/* | ||
Copyright 2013 Philipp Leitner | ||
Licensed 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 at.ac.tuwien.infosys.aic13.sentiment; | ||
|
||
import java.io.File; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
import at.ac.tuwien.infosys.cloudscale.annotations.FileDependency.DependentFile; | ||
import at.ac.tuwien.infosys.cloudscale.annotations.FileDependency.IFileDependencyProvider; | ||
|
||
public class WEKAFileProvider implements IFileDependencyProvider { | ||
|
||
@Override | ||
public DependentFile[] getDependentFiles() { | ||
|
||
List<DependentFile> dependentFiles = new ArrayList<>(); | ||
|
||
for(File file : new File("files").listFiles()) { | ||
if(file.isFile()) | ||
dependentFiles.add(new DependentFile(file.getPath())); | ||
} | ||
|
||
return dependentFiles.toArray(new DependentFile[0]); | ||
|
||
} | ||
|
||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file added
BIN
+4.55 MB
src/main/resources/files/weka.classifiers.functions.MultilayerPerceptron.model
Binary file not shown.
Binary file added
BIN
+7.88 MB
src/main/resources/files/weka.classifiers.functions.VotedPerceptron.model
Binary file not shown.
Binary file not shown.
Binary file not shown.