Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,12 @@ public void setAuthContext(AuthContext info) {
/* empty */
}

@Override
public AuthContext getAuthContext() {
// TODO Auto-generated method stub
return null;
}

@Override
public void dispose() {
/* empty */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,11 @@ public interface StorageAPI {
*/
public void setAuthContext(AuthContext info);

/**
* @return AuthContext instance associated with this Storage-API
*/
public AuthContext getAuthContext();

/**
* Downloads an object from a container.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
package com.intel.cosbench.controller.service;

import static com.intel.cosbench.model.WorkloadState.*;
import static java.util.concurrent.TimeUnit.*;

import java.util.*;
import java.util.concurrent.*;
Expand Down Expand Up @@ -165,21 +166,47 @@ private void processWorkload() throws InterruptedException {
workloadContext.setState(FINISHED);
}

private static String millisToHMS(long millis) {

long hrs = MILLISECONDS.toHours(millis) % 24;
long min = MILLISECONDS.toMinutes(millis) % 60;
long sec = MILLISECONDS.toSeconds(millis) % 60;

return hrs + ":" + min + "::" + sec;
}

private void runStage(StageContext stageContext) throws InterruptedException {
String id = stageContext.getId();
int closuredelay = stageContext.getStage().getClosuredelay();

String stageName = stageContext.getStage().getName();
String work0Type = stageContext.getStage().getWorks().get(0).getType();

LOGGER.info("begin to run stage {}", id);

LOGGER.info("============================================");
LOGGER.info("START WORK: {}", stageName);

long startStamp = System.currentTimeMillis();

workloadContext.setCurrentStage(stageContext);
if (stageContext.getStage().getName().equals("delay")
&& closuredelay > 0) {
if (stageName.equals("delay") && closuredelay > 0) {
executeDelay(stageContext, closuredelay);
} else {
executeStage(stageContext);
if (closuredelay > 0)

long elapsedTime = System.currentTimeMillis() - startStamp;

LOGGER.info("END WORK: {}, Time elapsed: {}", stageName, millisToHMS(elapsedTime));
LOGGER.info("============================================");
LOGGER.info("");

if(closuredelay > 0)
executeDelay(stageContext, closuredelay);
}
LOGGER.info("successfully ran stage {}", id);
}
}

LOGGER.info("successfully ran stage {}", id);
}

private void executeDelay(StageContext stageContext, int closuredelay)
throws InterruptedException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,7 @@ public WorkerContext[] getAllWorkers() {
return getAllItems().toArray(new WorkerContext[getSize()]);
}

public WorkerContext getWorkerByIndex(int index) {
return getItem(index);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import org.apache.commons.lang.StringUtils;

import com.intel.cosbench.api.auth.*;
import com.intel.cosbench.api.context.AuthContext;
import com.intel.cosbench.api.storage.*;
import com.intel.cosbench.config.*;
import com.intel.cosbench.config.castor.CastorConfigTools;
Expand Down Expand Up @@ -241,12 +242,35 @@ public void login() {

private void performLogin() {
missionContext.setState(AUTHING);
List<Agent> agents = createAuthAgents();

// Use worker 0 for authentication (and use the same token for other workers)
WorkerContext worker0 = missionContext.getWorkerRegistry().getWorkerByIndex(0);
List<Agent> agents = createAuthAgentFromContext(worker0);
executeAgents(agents, 0);

AuthContext authContext = worker0.getStorageApi().getAuthContext();
setAllWorkersAuthContext(authContext);

missionContext.setState(AUTHED);
}

private List<Agent> createAuthAgents() {
private void setAllWorkersAuthContext(AuthContext authContext) {
for (WorkerContext workerContext : missionContext.getWorkerRegistry())
workerContext.getStorageApi().setAuthContext(authContext);
}

/***
* Returns Size 1 list of Agents
* @param workerContext to create Agent for
*/
private List<Agent> createAuthAgentFromContext(WorkerContext workerContext) {
List<Agent> agents = new ArrayList<Agent>();
agents.add(Agents.newAuthAgent(retry, workerContext));
return agents;
}

@SuppressWarnings("unused")
private List<Agent> createAuthAgents() {
List<Agent> agents = new ArrayList<Agent>();
for (WorkerContext workerContext : missionContext.getWorkerRegistry())
agents.add(Agents.newAuthAgent(retry, workerContext));
Expand Down
5 changes: 5 additions & 0 deletions dev/cosbench-librados/.classpath
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,10 @@
<classpathentry kind="src" path="src"/>
<classpathentry kind="src" path="test"/>
<classpathentry kind="lib" path="rados-0.1.1.jar" sourcepath="/rados-java"/>
<classpathentry combineaccessrules="false" kind="src" path="/cosbench-api"/>
<classpathentry combineaccessrules="false" kind="src" path="/cosbench-config"/>
<classpathentry combineaccessrules="false" kind="src" path="/cosbench-core"/>
<classpathentry combineaccessrules="false" kind="src" path="/cosbench-log"/>
<classpathentry combineaccessrules="false" kind="src" path="/cosbench-log4j"/>
<classpathentry kind="output" path="bin"/>
</classpath>
6 changes: 6 additions & 0 deletions dev/cosbench-librados/.project
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@
<comment></comment>
<projects>
<project>cosbench</project>
<project>cosbench-api</project>
<project>cosbench-config</project>
<project>cosbench-core</project>
<project>cosbench-http</project>
<project>cosbench-log</project>
<project>cosbench-log4j</project>
</projects>
<buildSpec>
<buildCommand>
Expand Down
3 changes: 2 additions & 1 deletion dev/cosbench-librados/build.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
source.. = src/
source.. = src/,\
test/
output.. = bin/
bin.includes = META-INF/,\
rados-0.1.1.jar,\
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,12 +84,25 @@ public void setAuthContext(AuthContext info) {
client.init(token, storage_url);
} catch (Exception e) {
throw new StorageException(e);
}
logger.debug("using auth token: {}, storage url: {}", token, storage_url);
}

@Override
public void dispose() {
}
logger.debug("using auth token: {}, storage url: {}", token, storage_url);
}

@Override
public AuthContext getAuthContext() {
String token = client.getAuthToken();
String storage_url = client.getStorageURL();

AuthContext info = new AuthContext();
info.put(AUTH_TOKEN_KEY, token);
info.put(STORAGE_URL_KEY, storage_url);

logger.debug("returned auth token: {}, storage url: {}", token, storage_url);
return info;
}

@Override
public void dispose() {
super.dispose();
client.dispose();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import org.apache.http.entity.*;

import com.intel.cosbench.client.http.HttpClientUtil;
import com.intel.cosbench.log.*;

public class SwiftClient {

Expand Down Expand Up @@ -119,13 +120,20 @@ public void createContainer(String container) throws IOException,
SwiftException {
SwiftResponse response = null;
try {
Logger logger = LogFactory.getSystemLogger();
logger.info("Creating container with auth_token " + authToken);

method = HttpClientUtil.makeHttpPut(getContainerPath(container));
method.setHeader(X_AUTH_TOKEN, authToken);
response = new SwiftResponse(client.execute(method));
if (response.getStatusCode() == SC_CREATED)
if (response.getStatusCode() == SC_CREATED) {
logger.info("SUCCESS");
return;
if (response.getStatusCode() == SC_ACCEPTED)
}
if (response.getStatusCode() == SC_ACCEPTED) {
logger.info("SUCCESS");
return;
}
throw new SwiftException("unexpected return from server",
response.getResponseHeaders(), response.getStatusLine());
} finally {
Expand Down
Empty file modified pack.sh
100644 → 100755
Empty file.