-
Notifications
You must be signed in to change notification settings - Fork 242
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #114 from jialinsun/0.3.3.0
Fix issue #30
- Loading branch information
Showing
34 changed files
with
1,052 additions
and
27 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
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
54 changes: 54 additions & 0 deletions
54
dev/cosbench-controller/src/com/intel/cosbench/controller/loader/AbstractRunLoader.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,54 @@ | ||
/** | ||
Copyright 2013 Intel Corporation, All Rights Reserved. | ||
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 com.intel.cosbench.controller.loader; | ||
|
||
import java.io.*; | ||
import java.util.List; | ||
|
||
import com.intel.cosbench.model.WorkloadInfo; | ||
|
||
/** | ||
* This class is the base class for exporting run information. | ||
* | ||
* @author ywang19, qzheng7 | ||
* | ||
*/ | ||
abstract class AbstractRunLoader implements RunLoader{ | ||
|
||
protected BufferedReader reader; | ||
|
||
public AbstractRunLoader() { | ||
/* empty */ | ||
} | ||
|
||
@Override | ||
public void init(BufferedReader reader) throws IOException{ | ||
this.reader = reader; | ||
readHeader(); | ||
} | ||
|
||
@Override | ||
public List<WorkloadInfo> load() throws IOException{ | ||
return readWorkload(); | ||
} | ||
|
||
protected abstract void readHeader() throws IOException; | ||
|
||
protected abstract List<WorkloadInfo> readWorkload() throws IOException; | ||
|
||
} |
59 changes: 59 additions & 0 deletions
59
dev/cosbench-controller/src/com/intel/cosbench/controller/loader/AbstractSnapshotLoader.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,59 @@ | ||
/** | ||
Copyright 2013 Intel Corporation, All Rights Reserved. | ||
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 com.intel.cosbench.controller.loader; | ||
|
||
import java.io.*; | ||
|
||
import com.intel.cosbench.model.StageInfo; | ||
import com.intel.cosbench.model.WorkloadInfo; | ||
|
||
/** | ||
* This class is the base class for exporting run information. | ||
* | ||
* @author ywang19, qzheng7 | ||
* | ||
*/ | ||
abstract class AbstractSnapshotLoader implements SnapshotLoader{ | ||
|
||
protected BufferedReader reader; | ||
protected WorkloadInfo workloadContext; | ||
protected StageInfo stageContext; | ||
|
||
public AbstractSnapshotLoader() { | ||
/* empty */ | ||
} | ||
|
||
@Override | ||
public void init(BufferedReader reader, WorkloadInfo workloadContext, | ||
String stageId) throws IOException { | ||
this.reader = reader; | ||
this.workloadContext = workloadContext; | ||
this.stageContext = workloadContext.getStageInfo(stageId); | ||
} | ||
|
||
@Override | ||
public void load() throws IOException{ | ||
readHeader(); | ||
readSnapshot(); | ||
} | ||
|
||
protected abstract void readHeader() throws IOException; | ||
|
||
protected abstract void readSnapshot() throws IOException; | ||
|
||
} |
55 changes: 55 additions & 0 deletions
55
...bench-controller/src/com/intel/cosbench/controller/loader/AbstractWorkloadFileLoader.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,55 @@ | ||
/** | ||
Copyright 2013 Intel Corporation, All Rights Reserved. | ||
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 com.intel.cosbench.controller.loader; | ||
|
||
import java.io.*; | ||
|
||
import com.intel.cosbench.model.WorkloadInfo; | ||
|
||
/** | ||
* This class is the base class for exporting run information. | ||
* | ||
* @author ywang19, qzheng7 | ||
* | ||
*/ | ||
abstract class AbstractWorkloadFileLoader implements WorkloadFileLoader{ | ||
|
||
protected BufferedReader reader; | ||
protected WorkloadInfo workloadContext; | ||
|
||
public AbstractWorkloadFileLoader() { | ||
/* empty */ | ||
} | ||
|
||
@Override | ||
public void init(BufferedReader reader, WorkloadInfo workloadContext) throws IOException{ | ||
this.reader = reader; | ||
this.workloadContext = workloadContext; | ||
readHeader(); | ||
} | ||
|
||
@Override | ||
public void load() throws IOException{ | ||
readWorkload(); | ||
} | ||
|
||
protected abstract void readHeader() throws IOException; | ||
|
||
protected abstract void readWorkload() throws IOException; | ||
|
||
} |
93 changes: 93 additions & 0 deletions
93
dev/cosbench-controller/src/com/intel/cosbench/controller/loader/CSVRunLoader.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,93 @@ | ||
/** | ||
Copyright 2013 Intel Corporation, All Rights Reserved. | ||
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 com.intel.cosbench.controller.loader; | ||
|
||
import static com.intel.cosbench.controller.loader.Formats.DATETIME; | ||
|
||
import java.io.*; | ||
import java.text.ParseException; | ||
import java.util.ArrayList; | ||
import java.util.Date; | ||
import java.util.List; | ||
|
||
import com.intel.cosbench.bench.Report; | ||
import com.intel.cosbench.config.Workload; | ||
import com.intel.cosbench.controller.model.WorkloadContext; | ||
import com.intel.cosbench.model.WorkloadInfo; | ||
import com.intel.cosbench.model.WorkloadState; | ||
|
||
|
||
class CSVRunLoader extends AbstractRunLoader { | ||
|
||
private List<WorkloadInfo> workloads = new ArrayList<WorkloadInfo>(); | ||
|
||
public CSVRunLoader(BufferedReader reader) throws IOException { | ||
super.init(reader); | ||
} | ||
|
||
@Override | ||
protected void readHeader() throws IOException { | ||
this.reader.readLine(); | ||
} | ||
|
||
@Override | ||
protected List<WorkloadInfo> readWorkload() throws IOException { | ||
String workloadRecordLine = null; | ||
while ((workloadRecordLine = this.reader.readLine()) != null) { | ||
String[] columns = workloadRecordLine.split(","); | ||
WorkloadContext workloadContext = new WorkloadContext(); | ||
workloadContext.setArchived(true); | ||
workloadContext.setId(columns[0]); | ||
Report report = new Report(); | ||
workloadContext.setReport(report); | ||
Workload workload = new Workload(); | ||
workload.setName(columns[1]); | ||
workloadContext.setWorkload(workload); | ||
try { | ||
workloadContext.setSubmitDate(DATETIME.parse(columns[2])); | ||
workloadContext.setStartDate(DATETIME.parse(columns[3])); | ||
workloadContext.setStopDate(DATETIME.parse(columns[4])); | ||
} catch (ParseException e) { | ||
e.printStackTrace(); | ||
} | ||
|
||
workloadContext.setOpInfo(columns[5].split(" ")); | ||
for (WorkloadState state : WorkloadState.values()){ | ||
if(columns[6].equalsIgnoreCase(state.toString().toLowerCase())){ | ||
workloadContext.setState(state); | ||
break; | ||
} | ||
} | ||
int index = 6; | ||
while(++index <= columns.length-1) { | ||
String str[] = columns[index].split("@"); | ||
String stateName = str[0].trim(); | ||
Date stateDate = null; | ||
try { | ||
stateDate = DATETIME.parse(str[1].trim()); | ||
} catch (ParseException e) { | ||
e.printStackTrace(); | ||
} | ||
workloadContext.setState(stateName, stateDate); | ||
} | ||
workloads.add(workloadContext); | ||
} | ||
return workloads; | ||
} | ||
|
||
} |
Oops, something went wrong.