-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add EM plan and optimizer packages. #163
Merged
Merged
Changes from 2 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
5bcabc2
Add EM plan and optimizer packages.
bchocho 9baae4b
Address code review comments
bchocho d08903d
Change toString to use StringBuilder (addressing comments).
bchocho 82508c5
Add explicit else case to make code clearer (addressing comments).
bchocho 453c2b0
Add comments and refactor RandomOptimizer for better readability (add…
bchocho File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
32 changes: 32 additions & 0 deletions
32
services/elastic-memory/src/main/java/edu/snu/cay/services/em/optimizer/api/DataInfo.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,32 @@ | ||
/* | ||
* Copyright (C) 2015 Seoul National University | ||
* | ||
* 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 edu.snu.cay.services.em.optimizer.api; | ||
|
||
/** | ||
* Information about a dataType stored at an Evaluator. | ||
*/ | ||
public interface DataInfo { | ||
|
||
/** | ||
* @return the dataType | ||
*/ | ||
String getDataType(); | ||
|
||
/** | ||
* @return number of units stored with the dataType | ||
*/ | ||
int getNumUnits(); | ||
} |
33 changes: 33 additions & 0 deletions
33
...astic-memory/src/main/java/edu/snu/cay/services/em/optimizer/api/EvaluatorParameters.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,33 @@ | ||
/* | ||
* Copyright (C) 2015 Seoul National University | ||
* | ||
* 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 edu.snu.cay.services.em.optimizer.api; | ||
|
||
import java.util.Collection; | ||
|
||
/** | ||
* The current state of an evaluator, represented as a set of input parameters for an optimizer. | ||
*/ | ||
public interface EvaluatorParameters { | ||
/** | ||
* @return the evaluator's context ID | ||
*/ | ||
String getId(); | ||
|
||
/** | ||
* @return information about all data on the evaluator | ||
*/ | ||
Collection<DataInfo> getDataInfos(); | ||
} |
35 changes: 35 additions & 0 deletions
35
services/elastic-memory/src/main/java/edu/snu/cay/services/em/optimizer/api/Optimizer.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,35 @@ | ||
/* | ||
* Copyright (C) 2015 Seoul National University | ||
* | ||
* 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 edu.snu.cay.services.em.optimizer.api; | ||
|
||
import edu.snu.cay.services.em.plan.api.Plan; | ||
|
||
import java.util.Collection; | ||
|
||
/** | ||
* Given the current state of evaluators (as parameters) and available resources (as the number of available | ||
* evaluators), the optimizer generates an optimized plan. | ||
*/ | ||
public interface Optimizer { | ||
/** | ||
* @param activeEvaluators all currently active evaluators and their parameters | ||
* @param availableEvaluators the total number of evaluators available for optimization. | ||
* If availableEvaluators < activeEvaluators.size(), the optimized plan must delete evaluators. | ||
* If availableEvaluators > activeEvaluators.size(), the optimized plan may add evaluators. | ||
* @return the optimized plan | ||
*/ | ||
Plan optimize(Collection<EvaluatorParameters> activeEvaluators, int availableEvaluators); | ||
} |
20 changes: 20 additions & 0 deletions
20
...ices/elastic-memory/src/main/java/edu/snu/cay/services/em/optimizer/api/package-info.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,20 @@ | ||
/* | ||
* Copyright (C) 2015 Seoul National University | ||
* | ||
* 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. | ||
*/ | ||
/** | ||
* An optimizer that takes the current state of evaluators (as parameters) and available resources | ||
* (as the number of available evaluators), and generates a plan {@link edu.snu.cay.services.em.plan.api}. | ||
*/ | ||
package edu.snu.cay.services.em.optimizer.api; |
49 changes: 49 additions & 0 deletions
49
...ces/elastic-memory/src/main/java/edu/snu/cay/services/em/optimizer/impl/DataInfoImpl.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,49 @@ | ||
/* | ||
* Copyright (C) 2015 Seoul National University | ||
* | ||
* 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 edu.snu.cay.services.em.optimizer.impl; | ||
|
||
import edu.snu.cay.services.em.optimizer.api.DataInfo; | ||
|
||
/** | ||
* A plain-old-data implementation of DataInfo. | ||
*/ | ||
public final class DataInfoImpl implements DataInfo { | ||
private final String dataType; | ||
private final int numUnits; | ||
|
||
public DataInfoImpl(final String dataType, final int numUnits) { | ||
this.dataType = dataType; | ||
this.numUnits = numUnits; | ||
} | ||
|
||
@Override | ||
public String getDataType() { | ||
return dataType; | ||
} | ||
|
||
@Override | ||
public int getNumUnits() { | ||
return numUnits; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "DataInfoImpl{" + | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. StringBuilder |
||
"dataType='" + dataType + '\'' + | ||
", numUnits=" + numUnits + | ||
'}'; | ||
} | ||
} |
44 changes: 44 additions & 0 deletions
44
...-memory/src/main/java/edu/snu/cay/services/em/optimizer/impl/EvaluatorParametersImpl.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,44 @@ | ||
/* | ||
* Copyright (C) 2015 Seoul National University | ||
* | ||
* 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 edu.snu.cay.services.em.optimizer.impl; | ||
|
||
import edu.snu.cay.services.em.optimizer.api.DataInfo; | ||
import edu.snu.cay.services.em.optimizer.api.EvaluatorParameters; | ||
|
||
import java.util.Collection; | ||
|
||
/** | ||
* A plain-old-data implementation of EvaluatorParameters. | ||
*/ | ||
public final class EvaluatorParametersImpl implements EvaluatorParameters { | ||
private final String id; | ||
private final Collection<DataInfo> dataInfos; | ||
|
||
public EvaluatorParametersImpl(final String id, final Collection<DataInfo> dataInfos) { | ||
this.id = id; | ||
this.dataInfos = dataInfos; | ||
} | ||
|
||
@Override | ||
public String getId() { | ||
return id; | ||
} | ||
|
||
@Override | ||
public Collection<DataInfo> getDataInfos() { | ||
return dataInfos; | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this a context id or an evaluator id?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These should match the IDs passed to the
ElasticMemory
interface (in short: the context ID). In that interface, we loosely define it as a "identifier of the source evaluator." But, as far as I know, this has to be the Context ID. The Context ID is used in the SimpleEM example.@jsjason can you confirm that the Context ID is what we need for the
ElasticMemory
primitives?