|
From: <tre...@us...> - 2007-11-03 23:35:36
|
Revision: 557
http://ogoglio.svn.sourceforge.net/ogoglio/?rev=557&view=rev
Author: trevorolio
Date: 2007-11-03 16:35:40 -0700 (Sat, 03 Nov 2007)
Log Message:
-----------
Broke the load testing classes into a separate test package, added a way to load many spaces in addition to many users.
Modified Paths:
--------------
maven/trunk/ogoglio-common/src/main/java/com/ogoglio/viewer/j3d/J3DDataManager.java
maven/trunk/ogoglio-common/src/main/java/com/ogoglio/viewer/j3d/J3DRenderer.java
maven/trunk/ogoglio-common/src/main/java/com/ogoglio/viewer/j3d/J3DUserRenderable.java
Added Paths:
-----------
maven/trunk/ogoglio-common/src/test/java/com/ogoglio/loadtest/
maven/trunk/ogoglio-common/src/test/java/com/ogoglio/loadtest/Bot.java
maven/trunk/ogoglio-common/src/test/java/com/ogoglio/loadtest/MultispaceTests.java
maven/trunk/ogoglio-common/src/test/java/com/ogoglio/loadtest/MultiuserTests.java
Removed Paths:
-------------
maven/trunk/ogoglio-common/src/main/java/com/ogoglio/client/MultiuserTests.java
Deleted: maven/trunk/ogoglio-common/src/main/java/com/ogoglio/client/MultiuserTests.java
===================================================================
--- maven/trunk/ogoglio-common/src/main/java/com/ogoglio/client/MultiuserTests.java 2007-11-03 23:35:35 UTC (rev 556)
+++ maven/trunk/ogoglio-common/src/main/java/com/ogoglio/client/MultiuserTests.java 2007-11-03 23:35:40 UTC (rev 557)
@@ -1,211 +0,0 @@
-package com.ogoglio.client;
-
-import java.io.IOException;
-import java.net.URI;
-import java.util.Random;
-import java.util.Vector;
-
-import javax.media.j3d.Transform3D;
-import javax.vecmath.Vector3d;
-
-import com.ogoglio.client.model.SplinePath;
-import com.ogoglio.client.model.Thing;
-import com.ogoglio.client.model.User;
-import com.ogoglio.util.Log;
-import com.ogoglio.viewer.j3d.J3DSplinePath;
-
-public class MultiuserTests {
-
- private long spaceID = -1;
-
- private URI serviceURI = null;
-
- Vector robots = new Vector();
-
- Random random = new Random();
-
- public MultiuserTests(long spaceID, URI serviceURI) {
- this.spaceID = spaceID;
- this.serviceURI = serviceURI;
- }
-
- public synchronized void addRobot(Transform3D startPosition, boolean wander) throws IOException {
- UserRobot robot = new UserRobot(spaceID, serviceURI);
- robot.teleport(startPosition);
- robots.add(robot);
- if (wander) {
- robot.wander();
- }
- }
-
- private synchronized UserRobot[] getRobots() {
- return (UserRobot[]) robots.toArray(new UserRobot[0]);
- }
-
- public void cleanup() {
- UserRobot[] bots = getRobots();
- for (int i = 0; i < bots.length; i++) {
- bots[i].cleanup();
- }
- }
-
- private class UserRobot implements SpaceClient.Listener {
- SpaceClient spaceClient = null;
-
- WanderThread wanderThread = null;
-
- public UserRobot(long spaceID, URI serviceURI) throws IOException {
- String guestCookie = "guestRobot_Banger_Test_" + System.currentTimeMillis() + "_" + random.nextInt();
- if (guestCookie == null) {
- throw new IOException("Could not get a guest cookie");
- }
- spaceClient = new SpaceClient(spaceID, serviceURI, guestCookie, this);
- try {
- Thread.sleep(1000);
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
- wanderThread = new WanderThread(this);
- }
-
- public void wander() {
- wanderThread.start();
- }
-
- public void cleanup() {
- if (spaceClient != null) {
- spaceClient.cleanup();
- }
- }
-
- public void teleport(Transform3D position) {
- spaceClient.viewpointMotionStopped(position);
- }
-
- public void disconnected() {
- Log.error("UserRobot was disconnected");
- }
-
- public void receivedChatMessage(String username, String message) {
- }
-
- public void receivedSpaceTransfer(URI link) {
- }
-
- public void receivedLink(String displayName, String link) {
- }
-
- public void receivedCommandFocusRequest() {
- }
-
- public void receivedBrowserMessage(long sourceThingID, String message) {
- }
-
- public void receivedContextMenuRequest(Thing thing,String shapeName, int x, int y,long nonce) {
- }
-
- public void receivedContextMenuData(long nonce, String errorIfAny, Vector contextMenu) {
- }
-
- public void contextItemChosen(Thing thing, long nonce, String id) {
- }
-
- public void receivedInfoPanel(long sourceThingID, String nonce) {
- }
-
- }
-
- private class WanderThread extends Thread {
- UserRobot robot = null;
-
- public WanderThread(UserRobot robot) {
- this.robot = robot;
- }
-
- public void run() {
- User user = robot.spaceClient.getSpace().getUser(robot.spaceClient.getUsername());
- while(user == null) {
- try {
- sleep(1000);
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
- user = robot.spaceClient.getSpace().getUser(robot.spaceClient.getUsername());
- }
- Vector3d homePosition = new Vector3d(Math.abs(random.nextInt()) % 10, 0, Math.abs(random.nextInt()) % 10);
- System.out.println("Home position " + homePosition);
- Transform3D userPosition = new Transform3D();
- userPosition.setTranslation(homePosition);
- boolean lastSpun = true;
- while(true) {
- if(random.nextBoolean() || random.nextBoolean()){
- userPosition.setTranslation(homePosition);
- robot.spaceClient.viewpointMotionStopped(userPosition);
- try {
- sleep(1000 + Math.abs((random.nextInt() % 5000)));
- } catch (InterruptedException e) {
- break;
- }
- } else if(lastSpun) {
- userPosition.rotY(random.nextFloat() % (2 * Math.PI));
- userPosition.setTranslation(homePosition);
- SplinePath path = J3DSplinePath.getSplinePath(userPosition, 1, 0, 0, 2);
- robot.spaceClient.viewpointMotionChanged(path);
- try {
- sleep(3000 + Math.abs((random.nextInt() % 6000)));
- } catch (InterruptedException e) {
- break;
- }
- lastSpun = false;
- } else {
- userPosition.setTranslation(homePosition);
- SplinePath path = J3DSplinePath.getSplinePath(userPosition, 0, 1, 0, 2);
- robot.spaceClient.viewpointMotionChanged(path);
- try {
- sleep(1000 + Math.abs((random.nextInt() % 6000)));
- } catch (InterruptedException e) {
- break;
- }
- lastSpun = true;
- }
- }
- }
- }
-
- public static void main(String[] args) {
- if (args.length != 3) {
- Log.error("usage: ... spaceID serviceURI numRobots");
- return;
- }
- MultiuserTests tests = null;
- try {
- //If you are going to run a test like this, these should be pulled from
- //the properties files....
- //String serviceURI = "http://127.0.0.1:8080/og/";
- //String spaceURI = "http://127.0.0.1:8080/og/space/1/";
-
- long spaceID = Long.parseLong(args[0]);
- URI serviceURI = new URI(args[1]);
- tests = new MultiuserTests(spaceID, serviceURI);
-
- int numRobots = Integer.parseInt(args[2]);
- Transform3D startPosition = new Transform3D();
- for (int i = 0; i < numRobots; i++) {
- startPosition.setTranslation(new Vector3d(0, 0, -10));
- tests.addRobot(startPosition, true);
- Log.test("Added robot " + (i + 1) + " of " + numRobots);
- Thread.sleep(1000);
- }
-
- Thread.sleep(500000000);
- } catch (Throwable e) {
- e.printStackTrace();
- System.exit(1);
- } finally {
- if (tests != null) {
- tests.cleanup();
- }
- }
- }
-
-}
Modified: maven/trunk/ogoglio-common/src/main/java/com/ogoglio/viewer/j3d/J3DDataManager.java
===================================================================
--- maven/trunk/ogoglio-common/src/main/java/com/ogoglio/viewer/j3d/J3DDataManager.java 2007-11-03 23:35:35 UTC (rev 556)
+++ maven/trunk/ogoglio-common/src/main/java/com/ogoglio/viewer/j3d/J3DDataManager.java 2007-11-03 23:35:40 UTC (rev 557)
@@ -82,10 +82,13 @@
private boolean complainedAboutMemory = false;
- public J3DDataManager(boolean loadAppearances, TemplateDataProvider templateDataProvider, BodyDataProvider bodyDataProvider) {
+ private boolean watchMemory = false;
+
+ public J3DDataManager(boolean loadAppearances, TemplateDataProvider templateDataProvider, BodyDataProvider bodyDataProvider, boolean watchMemory) {
this.loadAppearances = loadAppearances;
this.templateDataProvider = templateDataProvider;
this.bodyDataProvider = bodyDataProvider;
+ this.watchMemory = watchMemory;
}
public BufferedImage getBodyTexture(String username, long bodyConfigurationID) {
@@ -565,6 +568,9 @@
}
private boolean atMaxMemory() {
+ if(!watchMemory){
+ return false;
+ }
boolean atMax = getHeapRemaining() < MINIMUM_REMAINING_HEAP;
if (atMax) {
Runtime.getRuntime().runFinalization();
Modified: maven/trunk/ogoglio-common/src/main/java/com/ogoglio/viewer/j3d/J3DRenderer.java
===================================================================
--- maven/trunk/ogoglio-common/src/main/java/com/ogoglio/viewer/j3d/J3DRenderer.java 2007-11-03 23:35:35 UTC (rev 556)
+++ maven/trunk/ogoglio-common/src/main/java/com/ogoglio/viewer/j3d/J3DRenderer.java 2007-11-03 23:35:40 UTC (rev 557)
@@ -121,7 +121,7 @@
this.username = username;
this.userInputListener = userInputListener;
this.offScreen = offScreen;
- this.dataManager = new J3DDataManager(!offScreen, templateDataProvider, bodyDataProvider);
+ this.dataManager = new J3DDataManager(!offScreen, templateDataProvider, bodyDataProvider, !offScreen);
setCapabilities(sceneRoot);
setCapabilities(usersGroup);
@@ -702,7 +702,6 @@
if (displayName.startsWith(WebConstants.GUEST_COOKIE_PREFIX)) {
displayName = J3DUserRenderable.convertGuestCookieToDisplayName(displayName);
}
- System.out.println("Setting name tag: " + displayName);
renderable.setNameTag(displayName);
}
Modified: maven/trunk/ogoglio-common/src/main/java/com/ogoglio/viewer/j3d/J3DUserRenderable.java
===================================================================
--- maven/trunk/ogoglio-common/src/main/java/com/ogoglio/viewer/j3d/J3DUserRenderable.java 2007-11-03 23:35:35 UTC (rev 556)
+++ maven/trunk/ogoglio-common/src/main/java/com/ogoglio/viewer/j3d/J3DUserRenderable.java 2007-11-03 23:35:40 UTC (rev 557)
@@ -95,6 +95,7 @@
}
public void initBody(J3DBodyData bodyData, BufferedImage customSkin) {
+ System.out.println("INIT BODY: " + user + " bodyData: " + bodyData + " skin " + customSkin);
bodyGroup.removeAllChildren();
this.bodyData = bodyData;
skin = new SkinLoader(bodyData, user.getBodyConfiguration(), customSkin).generateSkin();
@@ -295,9 +296,6 @@
displayName = displayName.substring(WebConstants.GUEST_COOKIE_PREFIX.length() + 1);
StringBuffer result = new StringBuffer(WebConstants.GUEST_DISPLAY_NAME_PREFIX);
String[] tokens = displayName.split(Pattern.quote("_"));
- for (int i = 0; i < tokens.length; i++) {
- System.out.println("TOKEN " + tokens[i]);
- }
int startIndex = tokens.length > 3 ? 3 : 0;
for (int i = startIndex; i < tokens.length; i++) {
result.append(" " + tokens[i]);
Added: maven/trunk/ogoglio-common/src/test/java/com/ogoglio/loadtest/Bot.java
===================================================================
--- maven/trunk/ogoglio-common/src/test/java/com/ogoglio/loadtest/Bot.java (rev 0)
+++ maven/trunk/ogoglio-common/src/test/java/com/ogoglio/loadtest/Bot.java 2007-11-03 23:35:40 UTC (rev 557)
@@ -0,0 +1,129 @@
+package com.ogoglio.loadtest;
+
+import java.io.IOException;
+import java.net.URI;
+import java.util.Random;
+import java.util.Vector;
+
+import javax.media.j3d.Transform3D;
+import javax.vecmath.Vector3d;
+
+import com.ogoglio.client.SpaceClient;
+import com.ogoglio.client.model.SplinePath;
+import com.ogoglio.client.model.Thing;
+import com.ogoglio.client.model.User;
+import com.ogoglio.util.Log;
+import com.ogoglio.viewer.j3d.J3DSplinePath;
+
+public class Bot implements SpaceClient.Listener {
+ SpaceClient spaceClient = null;
+
+ Random random = new Random();
+
+ WanderThread wanderThread = null;
+
+ public Bot(long spaceID, URI serviceURI) throws IOException {
+ String guestCookie = "guestRobot_Banger_Test_" + System.currentTimeMillis() + "_" + random.nextInt();
+ if (guestCookie == null) {
+ throw new IOException("Could not get a guest cookie");
+ }
+ spaceClient = new SpaceClient(spaceID, serviceURI, guestCookie, this);
+ }
+
+ public void wander() {
+ wanderThread = new WanderThread();
+ wanderThread.start();
+ }
+
+ public void cleanup() {
+ if (spaceClient != null) {
+ spaceClient.cleanup();
+ }
+ }
+
+ public void teleport(Transform3D position) {
+ spaceClient.viewpointMotionStopped(position);
+ }
+
+ public void disconnected() {
+ Log.error("UserRobot was disconnected");
+ }
+
+ public void receivedChatMessage(String username, String message) {
+ }
+
+ public void receivedSpaceTransfer(URI link) {
+ }
+
+ public void receivedLink(String displayName, String link) {
+ }
+
+ public void receivedCommandFocusRequest() {
+ }
+
+ public void receivedBrowserMessage(long sourceThingID, String message) {
+ }
+
+ public void receivedContextMenuRequest(Thing thing, String shapeName, int x, int y, long nonce) {
+ }
+
+ public void receivedContextMenuData(long nonce, String errorIfAny, Vector contextMenu) {
+ }
+
+ public void contextItemChosen(Thing thing, long nonce, String id) {
+ }
+
+ public void receivedInfoPanel(long sourceThingID, String nonce) {
+ }
+
+ private class WanderThread extends Thread {
+ public void run() {
+ User user = spaceClient.getSpace().getUser(spaceClient.getUsername());
+ while (user == null) {
+ try {
+ sleep(1000);
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ user = spaceClient.getSpace().getUser(spaceClient.getUsername());
+ }
+ Vector3d homePosition = new Vector3d(Math.abs(random.nextInt()) % 10, 0, -30 + Math.abs(random.nextInt()) % 10);
+ Transform3D userPosition = new Transform3D();
+ userPosition.setTranslation(homePosition);
+ boolean lastSpun = true;
+ while (true) {
+ if (random.nextBoolean() || random.nextBoolean()) {
+ userPosition.setTranslation(homePosition);
+ spaceClient.viewpointMotionStopped(userPosition);
+ try {
+ sleep(1000 + Math.abs((random.nextInt() % 5000)));
+ } catch (InterruptedException e) {
+ break;
+ }
+ } else if (lastSpun) {
+ userPosition.rotY(random.nextFloat() % (2 * Math.PI));
+ userPosition.setTranslation(homePosition);
+ SplinePath path = J3DSplinePath.getSplinePath(userPosition, 1, 0, 0, 2);
+ spaceClient.viewpointMotionChanged(path);
+ try {
+ sleep(3000 + Math.abs((random.nextInt() % 6000)));
+ } catch (InterruptedException e) {
+ break;
+ }
+ lastSpun = false;
+ } else {
+ userPosition.setTranslation(homePosition);
+ SplinePath path = J3DSplinePath.getSplinePath(userPosition, 0, 1, 0, 2);
+ spaceClient.viewpointMotionChanged(path);
+ try {
+ sleep(1000 + Math.abs((random.nextInt() % 6000)));
+ } catch (InterruptedException e) {
+ break;
+ }
+ lastSpun = true;
+ }
+ }
+ }
+ }
+
+}
Added: maven/trunk/ogoglio-common/src/test/java/com/ogoglio/loadtest/MultispaceTests.java
===================================================================
--- maven/trunk/ogoglio-common/src/test/java/com/ogoglio/loadtest/MultispaceTests.java (rev 0)
+++ maven/trunk/ogoglio-common/src/test/java/com/ogoglio/loadtest/MultispaceTests.java 2007-11-03 23:35:40 UTC (rev 557)
@@ -0,0 +1,67 @@
+package com.ogoglio.loadtest;
+
+import java.io.IOException;
+import java.net.URI;
+import java.util.Vector;
+
+import com.ogoglio.util.Log;
+
+public class MultispaceTests {
+
+ private URI serviceURI = null;
+
+ private long lowerSpaceID = -1;
+
+ private long upperSpaceID = -1;
+
+ Vector bots = new Vector();
+
+ public MultispaceTests(URI serviceURI, long lowerSpaceID, long upperSpaceID) {
+ this.lowerSpaceID = lowerSpaceID;
+ this.upperSpaceID = upperSpaceID;
+ this.serviceURI = serviceURI;
+ if (lowerSpaceID >= upperSpaceID) {
+ throw new IllegalArgumentException("lower space ID must be less than upper space ID");
+ }
+ }
+
+ public void startTests() throws IOException {
+ for (long i = lowerSpaceID; i <= upperSpaceID; i++) {
+ try {
+ Bot bot = new Bot(i, serviceURI);
+ System.out.println("Adding bot to space " + i);
+ bots.add(bot);
+ } catch (IOException e) {
+ System.out.println("Skipping space " + i);
+ }
+ }
+ }
+
+ public void stopTests() {
+ Bot[] theBots = (Bot[]) bots.toArray(new Bot[0]);
+ for (int i = 0; i < theBots.length; i++) {
+ theBots[i].cleanup();
+ }
+ }
+
+ public static void main(String[] args) {
+ if (args.length != 3) {
+ Log.error("usage: ... serviceURI lowerSpaceID upperSpaceID");
+ return;
+ }
+
+ URI serviceURI = URI.create(args[0]);
+ long lowerSpaceID = Long.parseLong(args[1]);
+ long upperSpaceID = Long.parseLong(args[2]);
+
+ MultispaceTests tests = new MultispaceTests(serviceURI, lowerSpaceID, upperSpaceID);
+ try {
+ tests.startTests();
+ Thread.sleep(500000000);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+
+ }
+
+}
Copied: maven/trunk/ogoglio-common/src/test/java/com/ogoglio/loadtest/MultiuserTests.java (from rev 549, maven/trunk/ogoglio-common/src/main/java/com/ogoglio/client/MultiuserTests.java)
===================================================================
--- maven/trunk/ogoglio-common/src/test/java/com/ogoglio/loadtest/MultiuserTests.java (rev 0)
+++ maven/trunk/ogoglio-common/src/test/java/com/ogoglio/loadtest/MultiuserTests.java 2007-11-03 23:35:40 UTC (rev 557)
@@ -0,0 +1,83 @@
+package com.ogoglio.loadtest;
+
+import java.io.IOException;
+import java.net.URI;
+import java.util.Random;
+import java.util.Vector;
+
+import javax.media.j3d.Transform3D;
+import javax.vecmath.Vector3d;
+
+import com.ogoglio.client.SpaceClient;
+import com.ogoglio.client.SpaceClient.Listener;
+import com.ogoglio.client.model.SplinePath;
+import com.ogoglio.client.model.Thing;
+import com.ogoglio.client.model.User;
+import com.ogoglio.util.Log;
+import com.ogoglio.viewer.j3d.J3DSplinePath;
+
+public class MultiuserTests {
+
+ private long spaceID = -1;
+
+ private URI serviceURI = null;
+
+ Vector robots = new Vector();
+
+ public MultiuserTests(long spaceID, URI serviceURI) {
+ this.spaceID = spaceID;
+ this.serviceURI = serviceURI;
+ }
+
+ public synchronized void addRobot(Transform3D startPosition, boolean wander) throws IOException {
+ Bot robot = new Bot(spaceID, serviceURI);
+ robot.teleport(startPosition);
+ robots.add(robot);
+ if (wander) {
+ robot.wander();
+ }
+ }
+
+ private synchronized Bot[] getRobots() {
+ return (Bot[]) robots.toArray(new Bot[0]);
+ }
+
+ public void cleanup() {
+ Bot[] bots = getRobots();
+ for (int i = 0; i < bots.length; i++) {
+ bots[i].cleanup();
+ }
+ }
+
+ public static void main(String[] args) {
+ if (args.length != 3) {
+ Log.error("usage: ... spaceID serviceURI numRobots");
+ return;
+ }
+ MultiuserTests tests = null;
+ try {
+ long spaceID = Long.parseLong(args[0]);
+ URI serviceURI = new URI(args[1]);
+ tests = new MultiuserTests(spaceID, serviceURI);
+
+ int numRobots = Integer.parseInt(args[2]);
+ Transform3D startPosition = new Transform3D();
+ for (int i = 0; i < numRobots; i++) {
+ startPosition.setTranslation(new Vector3d(0, 0, -50));
+ tests.addRobot(startPosition, true);
+ Log.test("Added robot " + (i + 1) + " of " + numRobots);
+ Thread.sleep(1000);
+ }
+
+ Thread.sleep(500000000);
+ } catch (Throwable e) {
+ e.printStackTrace();
+ System.exit(1);
+ } finally {
+ if (tests != null) {
+ tests.cleanup();
+ }
+ }
+ }
+
+}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|