mirror of https://github.com/BOINC/boinc.git
Changes to the rpc api that gets more details for the results and applications. Used in the task pull down.
This commit is contained in:
parent
ddc2d02e6e
commit
a597c2d24f
|
@ -98,8 +98,15 @@ public class TasksListAdapter extends ArrayAdapter<TaskData>{
|
|||
String deadline = (String) DateFormat.format("E d MMM yyyy hh:mm:ss aa", new Date(listItem.result.report_deadline*1000));
|
||||
((TextView) v.findViewById(R.id.deadline)).setText("Deadline: " + deadline);
|
||||
// set project name
|
||||
((TextView) v.findViewById(R.id.projectName)).setText("Project name: " + listItem.result.project_url);
|
||||
// TODO: set application friendly name
|
||||
String tempProjectName = listItem.result.project_url;
|
||||
if(listItem.result.project != null) {
|
||||
tempProjectName = listItem.result.project.getName();
|
||||
}
|
||||
((TextView) v.findViewById(R.id.projectName)).setText("Project name: " + tempProjectName);
|
||||
// set application friendly name
|
||||
if(listItem.result.app != null) {
|
||||
((TextView) v.findViewById(R.id.friendlyAppName)).setText("App Name: " + listItem.result.app.getName());
|
||||
}
|
||||
|
||||
ImageView suspendResume = (ImageView) v.findViewById(R.id.suspendResumeTask);
|
||||
if (listItem.currentRunState == listItem.nextRunState) {
|
||||
|
|
|
@ -45,6 +45,7 @@ import edu.berkeley.boinc.AppPreferences;
|
|||
import edu.berkeley.boinc.R;
|
||||
import edu.berkeley.boinc.rpc.AccountIn;
|
||||
import edu.berkeley.boinc.rpc.AccountOut;
|
||||
import edu.berkeley.boinc.rpc.CcState;
|
||||
import edu.berkeley.boinc.rpc.CcStatus;
|
||||
import edu.berkeley.boinc.rpc.GlobalPreferences;
|
||||
import edu.berkeley.boinc.rpc.Message;
|
||||
|
@ -945,19 +946,15 @@ public class Monitor extends Service {
|
|||
} else {
|
||||
if(showRpcCommands) Log.d(TAG, "getCcStatus");
|
||||
CcStatus status = rpc.getCcStatus();
|
||||
/*
|
||||
|
||||
if(showRpcCommands) Log.d(TAG, "getState");
|
||||
CcState state = rpc.getState();
|
||||
*/
|
||||
if(showRpcCommands) Log.d(TAG, "getResults");
|
||||
ArrayList<Result> results = rpc.getResults();
|
||||
if(showRpcCommands) Log.d(TAG, "getProjects");
|
||||
ArrayList<Project> projects = rpc.getProjectStatus();
|
||||
|
||||
if(showRpcCommands) Log.d(TAG, "getTransers");
|
||||
ArrayList<Transfer> transfers = rpc.getFileTransfers();
|
||||
|
||||
if( (status != null) && (results != null) && (projects != null) && (transfers != null)) {
|
||||
Monitor.getClientStatus().setClientStatus(status, results, projects, transfers);
|
||||
if( (status != null) && (state.results != null) && (state.projects != null) && (transfers != null)) {
|
||||
Monitor.getClientStatus().setClientStatus(status, state.results, state.projects, transfers);
|
||||
// Update status bar notification
|
||||
ClientNotification.getInstance().update(getApplicationContext(), getClientStatus());
|
||||
} else {
|
||||
|
|
|
@ -22,6 +22,16 @@ package edu.berkeley.boinc.rpc;
|
|||
public class App {
|
||||
public String name = "";
|
||||
public String user_friendly_name = "";
|
||||
public int non_cpu_intensive = 0;
|
||||
public Project project;
|
||||
|
||||
public boolean compare(App myapp) {
|
||||
//Check if name is the same
|
||||
if(!this.name.equalsIgnoreCase(myapp.name)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public final String getName() {
|
||||
return user_friendly_name.equals("") ? name : user_friendly_name;
|
||||
|
|
|
@ -22,4 +22,14 @@ package edu.berkeley.boinc.rpc;
|
|||
public class AppVersion {
|
||||
public String app_name;
|
||||
public int version_num;
|
||||
public String platform;
|
||||
public String plan_class;
|
||||
public String api_version;
|
||||
public double avg_ncpus;
|
||||
public double max_ncpus;
|
||||
|
||||
public double gpu_ram;
|
||||
|
||||
App app;
|
||||
Project project;
|
||||
}
|
||||
|
|
|
@ -100,6 +100,9 @@ public class AppsParser extends BaseParser {
|
|||
else if (localName.equalsIgnoreCase("user_friendly_name")) {
|
||||
mApp.user_friendly_name = mCurrentElement.toString();
|
||||
}
|
||||
else if (localName.equalsIgnoreCase("non_cpu_intensive")) {
|
||||
mApp.non_cpu_intensive = Integer.parseInt(mCurrentElement.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
mElementStarted = false;
|
||||
|
|
|
@ -21,6 +21,8 @@ package edu.berkeley.boinc.rpc;
|
|||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import android.util.Log;
|
||||
|
||||
public class CcState{
|
||||
public VersionInfo version_info;
|
||||
public HostInfo host_info;
|
||||
|
@ -31,4 +33,70 @@ public class CcState{
|
|||
public ArrayList<Result> results = new ArrayList<Result>();
|
||||
public boolean have_ati;
|
||||
public boolean have_cuda;
|
||||
|
||||
public void clearArrays() {
|
||||
projects.clear();
|
||||
apps.clear();
|
||||
app_versions.clear();
|
||||
workunits.clear();
|
||||
results.clear();
|
||||
}
|
||||
|
||||
public Project lookup_project(String testUrl) {
|
||||
int i = 0;
|
||||
for(i = 0; i < projects.size(); i++) {
|
||||
if(projects.get(i).master_url.equalsIgnoreCase(testUrl)) {
|
||||
return projects.get(i);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public App lookup_app(Project project, String appname) {
|
||||
for(int i = 0; i < apps.size(); i++) {
|
||||
if(!apps.get(i).project.compare(project)) {
|
||||
continue;
|
||||
}
|
||||
if(apps.get(i).name.equalsIgnoreCase(appname)) {
|
||||
return apps.get(i);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public Workunit lookup_wu(Project project, String wu_name) {
|
||||
for(int i = 0; i < workunits.size(); i++) {
|
||||
if(!workunits.get(i).project.compare(project)) {
|
||||
Log.d("Workunit", "Projects Do not compare");
|
||||
continue;
|
||||
}
|
||||
if(workunits.get(i).name.equalsIgnoreCase(wu_name)) {
|
||||
return workunits.get(i);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public AppVersion lookup_app_version(Project project, App app, int version_num, String plan_class) {
|
||||
for(int i = 0; i < app_versions.size(); i++) {
|
||||
//Check if projects match...
|
||||
if(!app_versions.get(i).project.compare(project)) {
|
||||
continue;
|
||||
}
|
||||
//Check if app matches
|
||||
if(!app_versions.get(i).app.compare(app)) {
|
||||
continue;
|
||||
}
|
||||
//checks version_num
|
||||
if(app_versions.get(i).version_num != version_num) {
|
||||
continue;
|
||||
}
|
||||
//Checks plan class
|
||||
if(!app_versions.get(i).plan_class.equalsIgnoreCase(plan_class)) {
|
||||
continue;
|
||||
}
|
||||
return app_versions.get(i);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -35,14 +35,19 @@ public class CcStateParser extends BaseParser {
|
|||
private boolean mInHostInfo = false;
|
||||
private ProjectsParser mProjectsParser = new ProjectsParser();
|
||||
private boolean mInProject = false;
|
||||
private Project myProject = new Project();
|
||||
private AppsParser mAppsParser = new AppsParser();
|
||||
private boolean mInApp = false;
|
||||
private App myApp = new App();
|
||||
private AppVersionsParser mAppVersionsParser = new AppVersionsParser();
|
||||
private boolean mInAppVersion = false;
|
||||
private AppVersion myAppVersion = new AppVersion();
|
||||
private WorkunitsParser mWorkunitsParser = new WorkunitsParser();
|
||||
private boolean mInWorkunit = false;
|
||||
private Workunit myWorkunit = new Workunit();
|
||||
private ResultsParser mResultsParser = new ResultsParser();
|
||||
private boolean mInResult = false;
|
||||
private Result myResult = new Result();
|
||||
|
||||
public final CcState getCcState() {
|
||||
return mCcState;
|
||||
|
@ -55,6 +60,13 @@ public class CcStateParser extends BaseParser {
|
|||
*/
|
||||
public static CcState parse(String rpcResult) {
|
||||
try {
|
||||
String tmp = rpcResult;
|
||||
while(tmp.length() > 4000) {
|
||||
Log.d(TAG, "WCG: " + tmp.substring(0, 4000));
|
||||
tmp = tmp.substring(4000);
|
||||
}
|
||||
Log.d(TAG, "WCG: " + tmp);
|
||||
|
||||
CcStateParser parser = new CcStateParser();
|
||||
Xml.parse(rpcResult, parser);
|
||||
return parser.getCcState();
|
||||
|
@ -72,16 +84,20 @@ public class CcStateParser extends BaseParser {
|
|||
// Commit sub-parsers data to resulting CcState
|
||||
mCcState.version_info = mVersionInfo;
|
||||
mCcState.host_info = mHostInfoParser.getHostInfo();
|
||||
mCcState.projects = mProjectsParser.getProjects();
|
||||
mCcState.apps = mAppsParser.getApps();
|
||||
mCcState.app_versions = mAppVersionsParser.getAppVersions();
|
||||
mCcState.workunits = mWorkunitsParser.getWorkunits();
|
||||
mCcState.results = mResultsParser.getResults();
|
||||
//mCcState.projects = mProjectsParser.getProjects();
|
||||
//mCcState.apps = mAppsParser.getApps();
|
||||
//mCcState.app_versions = mAppVersionsParser.getAppVersions();
|
||||
//mCcState.workunits = mWorkunitsParser.getWorkunits();
|
||||
//mCcState.results = mResultsParser.getResults();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException {
|
||||
super.startElement(uri, localName, qName, attributes);
|
||||
if (localName.equalsIgnoreCase("client_state")) {
|
||||
//Starting the query, clear mCcState
|
||||
mCcState.clearArrays();
|
||||
}
|
||||
if (localName.equalsIgnoreCase("host_info")) {
|
||||
// Just stepped inside <host_info>
|
||||
mInHostInfo = true;
|
||||
|
@ -185,6 +201,10 @@ public class CcStateParser extends BaseParser {
|
|||
if (localName.equalsIgnoreCase("project")) {
|
||||
// Closing tag of <project>
|
||||
mInProject = false;
|
||||
if(mProjectsParser.getProjects().size() > 0) {
|
||||
myProject = mProjectsParser.getProjects().get(mProjectsParser.getProjects().size() - 1);
|
||||
mCcState.projects.add(myProject);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (mInApp) {
|
||||
|
@ -194,6 +214,11 @@ public class CcStateParser extends BaseParser {
|
|||
if (localName.equalsIgnoreCase("app")) {
|
||||
// Closing tag of <app>
|
||||
mInApp = false;
|
||||
if(mAppsParser.getApps().size() > 0) {
|
||||
myApp = mAppsParser.getApps().get(mAppsParser.getApps().size() - 1);
|
||||
myApp.project = myProject;
|
||||
mCcState.apps.add(myApp);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (mInAppVersion) {
|
||||
|
@ -203,6 +228,12 @@ public class CcStateParser extends BaseParser {
|
|||
if (localName.equalsIgnoreCase("app_version")) {
|
||||
// Closing tag of <app_version>
|
||||
mInAppVersion = false;
|
||||
if(mAppVersionsParser.getAppVersions().size() > 0) {
|
||||
myAppVersion = mAppVersionsParser.getAppVersions().get(mAppVersionsParser.getAppVersions().size() - 1);
|
||||
myAppVersion.project = myProject;
|
||||
myAppVersion.app = mCcState.lookup_app(myProject, myAppVersion.app_name);
|
||||
mCcState.app_versions.add(myAppVersion);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (mInWorkunit) {
|
||||
|
@ -212,6 +243,12 @@ public class CcStateParser extends BaseParser {
|
|||
if (localName.equalsIgnoreCase("workunit")) {
|
||||
// Closing tag of <workunit>
|
||||
mInWorkunit = false;
|
||||
if(mWorkunitsParser.getWorkunits().size() > 0) {
|
||||
myWorkunit = mWorkunitsParser.getWorkunits().get(mWorkunitsParser.getWorkunits().size() - 1);
|
||||
myWorkunit.project = myProject;
|
||||
myWorkunit.app = mCcState.lookup_app(myProject, myWorkunit.app_name);
|
||||
mCcState.workunits.add(myWorkunit);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (mInResult) {
|
||||
|
@ -221,6 +258,18 @@ public class CcStateParser extends BaseParser {
|
|||
if (localName.equalsIgnoreCase("result")) {
|
||||
// Closing tag of <result>
|
||||
mInResult = false;
|
||||
|
||||
if(mResultsParser.getResults().size() > 0) {
|
||||
myResult = mResultsParser.getResults().get(mResultsParser.getResults().size() - 1);
|
||||
myResult.project = myProject;
|
||||
myResult.wup = mCcState.lookup_wu(myProject, myResult.wu_name);
|
||||
if(myResult.wup != null) {
|
||||
myResult.app = myResult.wup.app;
|
||||
myResult.avp = mCcState.lookup_app_version(myProject, myResult.app, myResult.version_num, myResult.plan_class);
|
||||
|
||||
}
|
||||
mCcState.results.add(myResult);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (mElementStarted) {
|
||||
|
|
|
@ -92,4 +92,17 @@ public class Project {
|
|||
public final String getName() {
|
||||
return project_name.equals("") ? master_url : project_name;
|
||||
}
|
||||
|
||||
public boolean compare(Project proj) {
|
||||
//Test that master_url's match...
|
||||
if(!this.master_url.equalsIgnoreCase(proj.master_url)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
//Test if user_name matches
|
||||
if(!this.user_name.equalsIgnoreCase(proj.user_name)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -65,5 +65,10 @@ public class Result {
|
|||
public String slot_path;
|
||||
|
||||
public String resources = null;
|
||||
|
||||
public Project project;
|
||||
public AppVersion avp;
|
||||
public App app;
|
||||
public Workunit wup;
|
||||
|
||||
}
|
||||
|
|
|
@ -1103,7 +1103,7 @@ public class RpcClient {
|
|||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Triggers operation on task in BOINC core client
|
||||
* @param operation operation to be triggered
|
||||
|
@ -1139,7 +1139,7 @@ public class RpcClient {
|
|||
mRequest.append(opTag);
|
||||
mRequest.append(">\n");
|
||||
sendRequest(mRequest.toString());
|
||||
|
||||
|
||||
SimpleReplyParser parser = SimpleReplyParser.parse(receiveReply());
|
||||
if (parser == null)
|
||||
return false;
|
||||
|
|
|
@ -27,4 +27,7 @@ public class Workunit {
|
|||
public double rsc_fpops_bound;
|
||||
public double rsc_memory_bound;
|
||||
public double rsc_disk_bound;
|
||||
|
||||
public Project project;
|
||||
public App app;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue