mirror of
https://bitbucket.org/projectswg/lightspeed.git
synced 2026-09-11 22:45:05 -04:00
Commit before massive changes
This commit is contained in:
@@ -38,15 +38,15 @@ import java.util.Set;
|
||||
|
||||
import com.projectswg.common.info.RelationalDatabase;
|
||||
import com.projectswg.common.info.RelationalServerFactory;
|
||||
import com.projectswg.lightspeed_frontend.data.BuildData;
|
||||
import com.projectswg.lightspeed_frontend.data.DeploymentData;
|
||||
import com.projectswg.lightspeed_frontend.data.ServerData;
|
||||
import com.projectswg.lightspeed_frontend.data.SharedBuildData;
|
||||
import com.projectswg.lightspeed_frontend.data.SharedDeploymentData;
|
||||
import com.projectswg.lightspeed_frontend.data.SharedServerData;
|
||||
|
||||
public class BackendData {
|
||||
|
||||
private final WeakMap<String, ServerData> serverMap;
|
||||
private final WeakMap<Long, BuildData> buildMap;
|
||||
private final WeakMap<Long, DeploymentData> deploymentMap;
|
||||
private final WeakMap<String, SharedServerData> serverMap;
|
||||
private final WeakMap<Long, SharedBuildData> buildMap;
|
||||
private final WeakMap<Long, SharedDeploymentData> deploymentMap;
|
||||
|
||||
public BackendData() {
|
||||
serverMap = new WeakMap<>();
|
||||
@@ -55,33 +55,33 @@ public class BackendData {
|
||||
loadServers();
|
||||
}
|
||||
|
||||
public void insertServer(ServerData server) {
|
||||
public void insertServer(SharedServerData server) {
|
||||
synchronized (serverMap) {
|
||||
if (serverMap.put(server.getName(), server) != null)
|
||||
return;
|
||||
}
|
||||
try (ServerTable serverTable = new ServerTable()) {
|
||||
serverTable.insertServer(new ServerInformation(server.getName(), server.getDirectory(), server.getJvmArguments()));
|
||||
serverTable.insertServer(new SQLServerData(server.getName(), server.getDirectory(), server.getJvmArguments()));
|
||||
}
|
||||
}
|
||||
|
||||
public void insertBuild(BuildData build) {
|
||||
public void insertBuild(SharedBuildData build) {
|
||||
synchronized (buildMap) {
|
||||
if (buildMap.put(build.getId(), build) != null)
|
||||
return;
|
||||
}
|
||||
try (BuildHistoryTable buildTable = new BuildHistoryTable()) {
|
||||
buildTable.insertBuildHistory(new BuildInformation(build));
|
||||
buildTable.insertBuildHistory(new SQLBuildData(build));
|
||||
}
|
||||
}
|
||||
|
||||
public void insertDeployment(DeploymentData deployment) {
|
||||
public void insertDeployment(SharedDeploymentData deployment) {
|
||||
synchronized (deploymentMap) {
|
||||
if (deploymentMap.put(deployment.getId(), deployment) != null)
|
||||
return;
|
||||
}
|
||||
try (DeploymentTable deploymentTable = new DeploymentTable()) {
|
||||
deploymentTable.insertDeployment(new DeploymentInformation(deployment));
|
||||
deploymentTable.insertDeployment(new SQLDeploymentData(deployment));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -94,19 +94,19 @@ public class BackendData {
|
||||
}
|
||||
}
|
||||
|
||||
public List<ServerData> getServerList() {
|
||||
List<ServerData> servers = new ArrayList<>(serverMap.size());
|
||||
public List<SharedServerData> getServerList() {
|
||||
List<SharedServerData> servers = new ArrayList<>(serverMap.size());
|
||||
synchronized (serverMap) {
|
||||
for (Entry<String, ServerData> e : serverMap.entrySet()) {
|
||||
for (Entry<String, SharedServerData> e : serverMap.entrySet()) {
|
||||
servers.add(e.getValue());
|
||||
}
|
||||
}
|
||||
return servers;
|
||||
}
|
||||
|
||||
public ServerData getServer(String serverId) {
|
||||
public SharedServerData getServer(String serverId) {
|
||||
synchronized (serverMap) {
|
||||
ServerData server = serverMap.get(serverId);
|
||||
SharedServerData server = serverMap.get(serverId);
|
||||
if (server != null)
|
||||
return server;
|
||||
server = fetchServer(serverId);
|
||||
@@ -115,9 +115,9 @@ public class BackendData {
|
||||
}
|
||||
}
|
||||
|
||||
public BuildData getBuild(long buildId) {
|
||||
public SharedBuildData getBuild(long buildId) {
|
||||
synchronized (buildMap) {
|
||||
BuildData build = buildMap.get(buildId);
|
||||
SharedBuildData build = buildMap.get(buildId);
|
||||
if (build != null)
|
||||
return build;
|
||||
build = fetchBuild(buildId);
|
||||
@@ -131,7 +131,7 @@ public class BackendData {
|
||||
try (RelationalDatabase db = RelationalServerFactory.getServerDatabase("lightspeed.db")) {
|
||||
try (ServerTable serverTable = new ServerTable(db)) {
|
||||
for (String serverId : serverTable.getServerStrings()) {
|
||||
ServerData server = fetchServer(serverId);
|
||||
SharedServerData server = fetchServer(serverId);
|
||||
serverMap.put(server.getName(), server);
|
||||
}
|
||||
}
|
||||
@@ -139,20 +139,20 @@ public class BackendData {
|
||||
}
|
||||
}
|
||||
|
||||
private ServerData fetchServer(String serverId) {
|
||||
private SharedServerData fetchServer(String serverId) {
|
||||
try (RelationalDatabase db = RelationalServerFactory.getServerDatabase("lightspeed.db")) {
|
||||
try (ServerTable serverTable = new ServerTable(db)) {
|
||||
ServerData server = createServerFromInfo(serverTable.getServerById(serverId));
|
||||
SharedServerData server = createServerFromInfo(serverTable.getServerById(serverId));
|
||||
fetchBuildHistory(db, server);
|
||||
return server;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void fetchBuildHistory(RelationalDatabase db, ServerData server) {
|
||||
private void fetchBuildHistory(RelationalDatabase db, SharedServerData server) {
|
||||
try (BuildHistoryTable buildTable = new BuildHistoryTable(db)) {
|
||||
for (BuildInformation info : buildTable.getBuildHistory(server.getName())) {
|
||||
BuildData build = createBuildFromInfo(server, info);
|
||||
for (SQLBuildData info : buildTable.getBuildHistory(server.getName())) {
|
||||
SharedBuildData build = createBuildFromInfo(server, info);
|
||||
synchronized (buildMap) {
|
||||
buildMap.put(build.getId(), build);
|
||||
}
|
||||
@@ -162,22 +162,22 @@ public class BackendData {
|
||||
}
|
||||
}
|
||||
|
||||
private BuildData fetchBuild(long buildId) {
|
||||
private SharedBuildData fetchBuild(long buildId) {
|
||||
try (RelationalDatabase db = RelationalServerFactory.getServerDatabase("lightspeed.db")) {
|
||||
try (BuildHistoryTable buildTable = new BuildHistoryTable(db)) {
|
||||
BuildInformation info = buildTable.getBuildById(buildId);
|
||||
ServerData server = getServer(info.getServerId());
|
||||
BuildData build = createBuildFromInfo(server, info);
|
||||
SQLBuildData info = buildTable.getBuildById(buildId);
|
||||
SharedServerData server = getServer(info.getServerId());
|
||||
SharedBuildData build = createBuildFromInfo(server, info);
|
||||
fetchDeploymentHistory(db, build);
|
||||
return build;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void fetchDeploymentHistory(RelationalDatabase db, BuildData build) {
|
||||
private void fetchDeploymentHistory(RelationalDatabase db, SharedBuildData build) {
|
||||
try (DeploymentTable deploymentTable = new DeploymentTable(db)) {
|
||||
for (DeploymentInformation info : deploymentTable.getDeployments(build.getId())) {
|
||||
DeploymentData deployment = createDeploymentFromInfo(build, info);
|
||||
for (SQLDeploymentData info : deploymentTable.getDeployments(build.getId())) {
|
||||
SharedDeploymentData deployment = createDeploymentFromInfo(build, info);
|
||||
build.addDeployment(deployment);
|
||||
synchronized (deploymentMap) {
|
||||
deploymentMap.put(deployment.getId(), deployment);
|
||||
@@ -186,15 +186,15 @@ public class BackendData {
|
||||
}
|
||||
}
|
||||
|
||||
private ServerData createServerFromInfo(ServerInformation info) {
|
||||
ServerData server = new ServerData(info.getId());
|
||||
private SharedServerData createServerFromInfo(SQLServerData info) {
|
||||
SharedServerData server = new SharedServerData(info.getId());
|
||||
server.setDirectory(info.getDir());
|
||||
server.setJvmArguments(info.getJvmArgs());
|
||||
return server;
|
||||
}
|
||||
|
||||
private BuildData createBuildFromInfo(ServerData server, BuildInformation info) {
|
||||
BuildData build = new BuildData(info.getId(), server);
|
||||
private SharedBuildData createBuildFromInfo(SharedServerData server, SQLBuildData info) {
|
||||
SharedBuildData build = new SharedBuildData(info.getId(), server);
|
||||
build.setTime(info.getCompletedTime());
|
||||
build.setBuildString(info.getBuildString());
|
||||
build.setTestString(info.getTestString());
|
||||
@@ -208,8 +208,8 @@ public class BackendData {
|
||||
return build;
|
||||
}
|
||||
|
||||
private DeploymentData createDeploymentFromInfo(BuildData build, DeploymentInformation info) {
|
||||
DeploymentData deployment = new DeploymentData(info.getId(), build);
|
||||
private SharedDeploymentData createDeploymentFromInfo(SharedBuildData build, SQLDeploymentData info) {
|
||||
SharedDeploymentData deployment = new SharedDeploymentData(info.getId(), build);
|
||||
deployment.setStartTime(info.getStartTime());
|
||||
deployment.setEndTime(info.getEndTime());
|
||||
return deployment;
|
||||
|
||||
@@ -34,8 +34,8 @@ import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.projectswg.common.data.BuildInformation;
|
||||
import com.projectswg.common.data.BuildInformation.BuildInformationBuilder;
|
||||
import com.projectswg.common.data.SQLBuildData;
|
||||
import com.projectswg.common.data.SQLBuildData.BuildInformationBuilder;
|
||||
import com.projectswg.common.data.TestDetails;
|
||||
import com.projectswg.common.info.RelationalDatabase;
|
||||
import com.projectswg.common.info.RelationalServerFactory;
|
||||
@@ -75,8 +75,8 @@ class BuildHistoryTable implements AutoCloseable {
|
||||
safeClose(getBuildByIdStatement);
|
||||
}
|
||||
|
||||
public List<BuildInformation> getBuildHistory(String serverId) {
|
||||
List<BuildInformation> history = new ArrayList<>(STANDARD_HISTORY_SIZE);
|
||||
public List<SQLBuildData> getBuildHistory(String serverId) {
|
||||
List<SQLBuildData> history = new ArrayList<>(STANDARD_HISTORY_SIZE);
|
||||
try {
|
||||
synchronized (getBuildHistoryStatement) {
|
||||
getBuildHistoryStatement.setString(1, serverId);
|
||||
@@ -91,7 +91,7 @@ class BuildHistoryTable implements AutoCloseable {
|
||||
return history;
|
||||
}
|
||||
|
||||
public BuildInformation getBuildById(long buildId) {
|
||||
public SQLBuildData getBuildById(long buildId) {
|
||||
try {
|
||||
synchronized (getBuildByIdStatement) {
|
||||
getBuildByIdStatement.setLong(1, buildId);
|
||||
@@ -105,7 +105,7 @@ class BuildHistoryTable implements AutoCloseable {
|
||||
return null;
|
||||
}
|
||||
|
||||
private BuildInformation createBuildFromSet(ResultSet set) throws SQLException {
|
||||
private SQLBuildData createBuildFromSet(ResultSet set) throws SQLException {
|
||||
BuildInformationBuilder builder = new BuildInformationBuilder();
|
||||
builder.setId(set.getLong("id"));
|
||||
builder.setCompletedTime(set.getLong("time"));
|
||||
@@ -126,7 +126,7 @@ class BuildHistoryTable implements AutoCloseable {
|
||||
return builder.build();
|
||||
}
|
||||
|
||||
public void insertBuildHistory(BuildInformation build) {
|
||||
public void insertBuildHistory(SQLBuildData build) {
|
||||
try {
|
||||
synchronized (insertBuildHistoryStatement) {
|
||||
insertBuildHistoryStatement.setLong(1, build.getId());
|
||||
|
||||
@@ -33,8 +33,8 @@ import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.projectswg.common.data.DeploymentInformation;
|
||||
import com.projectswg.common.data.DeploymentInformation.DeploymentInformationBuilder;
|
||||
import com.projectswg.common.data.SQLDeploymentData;
|
||||
import com.projectswg.common.data.SQLDeploymentData.DeploymentInformationBuilder;
|
||||
import com.projectswg.common.info.RelationalDatabase;
|
||||
import com.projectswg.common.info.RelationalServerFactory;
|
||||
|
||||
@@ -82,7 +82,7 @@ class DeploymentTable implements AutoCloseable {
|
||||
safeClose(getLastDeploymentStatement);
|
||||
}
|
||||
|
||||
public boolean insertDeployment(DeploymentInformation deployment) {
|
||||
public boolean insertDeployment(SQLDeploymentData deployment) {
|
||||
try {
|
||||
synchronized (insertDeploymentStatement) {
|
||||
insertDeploymentStatement.setLong(1, deployment.getId());
|
||||
@@ -98,7 +98,7 @@ class DeploymentTable implements AutoCloseable {
|
||||
return false;
|
||||
}
|
||||
|
||||
public DeploymentInformation getDeploymentById(long id) {
|
||||
public SQLDeploymentData getDeploymentById(long id) {
|
||||
try {
|
||||
synchronized (getDeploymentByIdStatement) {
|
||||
getDeploymentByIdStatement.setLong(1, id);
|
||||
@@ -112,7 +112,7 @@ class DeploymentTable implements AutoCloseable {
|
||||
return null;
|
||||
}
|
||||
|
||||
public DeploymentInformation getLastDeployment(String serverId) {
|
||||
public SQLDeploymentData getLastDeployment(String serverId) {
|
||||
try {
|
||||
synchronized (getLastDeploymentStatement) {
|
||||
getLastDeploymentStatement.setString(1, serverId);
|
||||
@@ -126,8 +126,8 @@ class DeploymentTable implements AutoCloseable {
|
||||
return null;
|
||||
}
|
||||
|
||||
public List<DeploymentInformation> getDeployments(String serverId) {
|
||||
List<DeploymentInformation> deployments = new ArrayList<>();
|
||||
public List<SQLDeploymentData> getDeployments(String serverId) {
|
||||
List<SQLDeploymentData> deployments = new ArrayList<>();
|
||||
try {
|
||||
synchronized (getDeploymentsByServerStatement) {
|
||||
getDeploymentsByServerStatement.setString(1, serverId);
|
||||
@@ -141,8 +141,8 @@ class DeploymentTable implements AutoCloseable {
|
||||
return deployments;
|
||||
}
|
||||
|
||||
public List<DeploymentInformation> getDeployments(long buildId) {
|
||||
List<DeploymentInformation> deployments = new ArrayList<>();
|
||||
public List<SQLDeploymentData> getDeployments(long buildId) {
|
||||
List<SQLDeploymentData> deployments = new ArrayList<>();
|
||||
try {
|
||||
synchronized (getDeploymentsByBuildStatement) {
|
||||
getDeploymentsByBuildStatement.setLong(1, buildId);
|
||||
@@ -156,7 +156,7 @@ class DeploymentTable implements AutoCloseable {
|
||||
return deployments;
|
||||
}
|
||||
|
||||
private DeploymentInformation createDeploymentFromSet(ResultSet set) throws SQLException {
|
||||
private SQLDeploymentData createDeploymentFromSet(ResultSet set) throws SQLException {
|
||||
return new DeploymentInformationBuilder()
|
||||
.setId(set.getLong("id"))
|
||||
.setServerId(set.getString("server_id"))
|
||||
|
||||
+11
-11
@@ -30,13 +30,13 @@ package com.projectswg.common.data;
|
||||
import java.io.File;
|
||||
|
||||
import com.projectswg.common.utilities.TimeUtilities;
|
||||
import com.projectswg.lightspeed.build.InstallationDetails;
|
||||
import com.projectswg.lightspeed.build.ServerBuildData;
|
||||
import com.projectswg.lightspeed.build.InstallationState;
|
||||
import com.projectswg.lightspeed_frontend.data.BuildData;
|
||||
import com.projectswg.lightspeed_frontend.data.SharedBuildData;
|
||||
|
||||
import me.joshlarson.json.JSONObject;
|
||||
|
||||
class BuildInformation {
|
||||
class SQLBuildData {
|
||||
|
||||
private long id;
|
||||
private String serverId;
|
||||
@@ -51,7 +51,7 @@ class BuildInformation {
|
||||
private TestDetails testDetails;
|
||||
private File jar;
|
||||
|
||||
public BuildInformation(long id, String serverId, InstallationDetails installation, File jar) {
|
||||
public SQLBuildData(long id, String serverId, ServerBuildData installation, File jar) {
|
||||
this.id = id;
|
||||
this.serverId = serverId;
|
||||
this.buildString = installation.getBuildString();
|
||||
@@ -66,7 +66,7 @@ class BuildInformation {
|
||||
this.jar = jar;
|
||||
}
|
||||
|
||||
public BuildInformation(BuildData build) {
|
||||
public SQLBuildData(SharedBuildData build) {
|
||||
this.id = build.getId();
|
||||
this.serverId = build.getServer().getName();
|
||||
this.buildString = build.getBuildString();
|
||||
@@ -81,7 +81,7 @@ class BuildInformation {
|
||||
this.jar = build.getJar();
|
||||
}
|
||||
|
||||
public BuildInformation(JSONObject json) {
|
||||
public SQLBuildData(JSONObject json) {
|
||||
this.id = json.getLong("id");
|
||||
this.serverId = json.getString("server_id");
|
||||
this.buildString = json.getString("build_string");
|
||||
@@ -96,7 +96,7 @@ class BuildInformation {
|
||||
this.jar = null;
|
||||
}
|
||||
|
||||
private BuildInformation() {
|
||||
private SQLBuildData() {
|
||||
this.id = 0;
|
||||
this.serverId = "";
|
||||
this.buildString = "";
|
||||
@@ -184,7 +184,7 @@ class BuildInformation {
|
||||
|
||||
public static class BuildInformationBuilder {
|
||||
|
||||
private BuildInformation build = new BuildInformation();
|
||||
private SQLBuildData build = new SQLBuildData();
|
||||
|
||||
public BuildInformationBuilder setId(long id) { build.id = id; return this; }
|
||||
public BuildInformationBuilder setServerId(String serverId) { build.serverId = serverId; return this; }
|
||||
@@ -198,9 +198,9 @@ class BuildInformation {
|
||||
public BuildInformationBuilder setCancelled(boolean cancelled) { build.cancelled = cancelled; return this; }
|
||||
public BuildInformationBuilder setTestDetails(TestDetails testDetails) { build.testDetails = testDetails; return this; }
|
||||
public BuildInformationBuilder setJar(File jar) { build.jar = jar; return this; }
|
||||
public BuildInformation build() {
|
||||
BuildInformation ret = build;
|
||||
build = new BuildInformation();
|
||||
public SQLBuildData build() {
|
||||
SQLBuildData ret = build;
|
||||
build = new SQLBuildData();
|
||||
return ret;
|
||||
}
|
||||
|
||||
+9
-9
@@ -28,11 +28,11 @@
|
||||
package com.projectswg.common.data;
|
||||
|
||||
import com.projectswg.common.utilities.TimeUtilities;
|
||||
import com.projectswg.lightspeed_frontend.data.DeploymentData;
|
||||
import com.projectswg.lightspeed_frontend.data.SharedDeploymentData;
|
||||
|
||||
import me.joshlarson.json.JSONObject;
|
||||
|
||||
class DeploymentInformation {
|
||||
class SQLDeploymentData {
|
||||
|
||||
private long id;
|
||||
private String serverId;
|
||||
@@ -40,7 +40,7 @@ class DeploymentInformation {
|
||||
private long startTime;
|
||||
private long endTime;
|
||||
|
||||
public DeploymentInformation(DeploymentData deployment) {
|
||||
public SQLDeploymentData(SharedDeploymentData deployment) {
|
||||
this.id = deployment.getId();
|
||||
this.serverId = deployment.getServer().getName();
|
||||
this.buildId = deployment.getBuild().getId();
|
||||
@@ -48,7 +48,7 @@ class DeploymentInformation {
|
||||
this.endTime = deployment.getEndTime();
|
||||
}
|
||||
|
||||
public DeploymentInformation(JSONObject json) {
|
||||
public SQLDeploymentData(JSONObject json) {
|
||||
this.id = json.getLong("id");
|
||||
this.serverId = json.getString("server_id");
|
||||
this.buildId = json.getLong("build_id");
|
||||
@@ -56,7 +56,7 @@ class DeploymentInformation {
|
||||
this.endTime = TimeUtilities.getTimeFromStringUtc(json.getString("end_time"));
|
||||
}
|
||||
|
||||
private DeploymentInformation() {
|
||||
private SQLDeploymentData() {
|
||||
this.id = 0;
|
||||
this.serverId = "";
|
||||
this.buildId = 0;
|
||||
@@ -100,16 +100,16 @@ class DeploymentInformation {
|
||||
|
||||
public static class DeploymentInformationBuilder {
|
||||
|
||||
private DeploymentInformation deploy = new DeploymentInformation();
|
||||
private SQLDeploymentData deploy = new SQLDeploymentData();
|
||||
|
||||
public DeploymentInformationBuilder setId(long id) { deploy.id = id; return this; }
|
||||
public DeploymentInformationBuilder setServerId(String id) { deploy.serverId = id; return this; }
|
||||
public DeploymentInformationBuilder setBuildId(long id) { deploy.buildId = id; return this; }
|
||||
public DeploymentInformationBuilder setStartTime(long time) { deploy.startTime = time; return this; }
|
||||
public DeploymentInformationBuilder setEndTime(long time) { deploy.endTime = time; return this; }
|
||||
public DeploymentInformation build() {
|
||||
DeploymentInformation ret = deploy;
|
||||
deploy = new DeploymentInformation();
|
||||
public SQLDeploymentData build() {
|
||||
SQLDeploymentData ret = deploy;
|
||||
deploy = new SQLDeploymentData();
|
||||
return ret;
|
||||
}
|
||||
|
||||
+2
-2
@@ -27,13 +27,13 @@
|
||||
***********************************************************************************/
|
||||
package com.projectswg.common.data;
|
||||
|
||||
class ServerInformation {
|
||||
class SQLServerData {
|
||||
|
||||
private final String id;
|
||||
private final String dir;
|
||||
private final String jvmArgs;
|
||||
|
||||
public ServerInformation(String id, String dir, String jvmArgs) {
|
||||
public SQLServerData(String id, String dir, String jvmArgs) {
|
||||
this.id = id;
|
||||
this.dir = dir;
|
||||
this.jvmArgs = jvmArgs;
|
||||
@@ -80,7 +80,7 @@ class ServerTable implements AutoCloseable {
|
||||
safeClose(getServersStatement);
|
||||
}
|
||||
|
||||
public boolean insertServer(ServerInformation server) {
|
||||
public boolean insertServer(SQLServerData server) {
|
||||
try {
|
||||
synchronized (insertServerStatement) {
|
||||
insertServerStatement.setString(1, server.getId());
|
||||
@@ -106,13 +106,13 @@ class ServerTable implements AutoCloseable {
|
||||
return false;
|
||||
}
|
||||
|
||||
public ServerInformation getServerByDirectory(File dir) {
|
||||
public SQLServerData getServerByDirectory(File dir) {
|
||||
try {
|
||||
synchronized (getServerByDirStatement) {
|
||||
getServerByDirStatement.setString(1, dir.getAbsolutePath());
|
||||
ResultSet set = getServerByDirStatement.executeQuery();
|
||||
if (set.next())
|
||||
return new ServerInformation(set.getString("id"), dir.getAbsolutePath(), set.getString("jvm_arguments"));
|
||||
return new SQLServerData(set.getString("id"), dir.getAbsolutePath(), set.getString("jvm_arguments"));
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
@@ -120,13 +120,13 @@ class ServerTable implements AutoCloseable {
|
||||
return null;
|
||||
}
|
||||
|
||||
public ServerInformation getServerById(String id) {
|
||||
public SQLServerData getServerById(String id) {
|
||||
try {
|
||||
synchronized (getServerByIdStatement) {
|
||||
getServerByIdStatement.setString(1, id);
|
||||
ResultSet set = getServerByIdStatement.executeQuery();
|
||||
if (set.next())
|
||||
return new ServerInformation(id, set.getString("directory"), set.getString("jvm_arguments"));
|
||||
return new SQLServerData(id, set.getString("directory"), set.getString("jvm_arguments"));
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
|
||||
@@ -28,28 +28,28 @@
|
||||
package com.projectswg.common.intents;
|
||||
|
||||
import com.projectswg.common.control.Intent;
|
||||
import com.projectswg.lightspeed_frontend.data.BuildData;
|
||||
import com.projectswg.lightspeed_frontend.data.SharedBuildData;
|
||||
|
||||
public class LaunchStarshipIntent extends Intent {
|
||||
|
||||
public static final String TYPE = "LaunchStarshipIntent";
|
||||
|
||||
private BuildData build;
|
||||
private SharedBuildData build;
|
||||
|
||||
public LaunchStarshipIntent() {
|
||||
this(null);
|
||||
}
|
||||
|
||||
public LaunchStarshipIntent(BuildData build) {
|
||||
public LaunchStarshipIntent(SharedBuildData build) {
|
||||
super(TYPE);
|
||||
setBuild(build);
|
||||
}
|
||||
|
||||
public BuildData getBuild() {
|
||||
public SharedBuildData getBuild() {
|
||||
return build;
|
||||
}
|
||||
|
||||
public void setBuild(BuildData build) {
|
||||
public void setBuild(SharedBuildData build) {
|
||||
this.build = build;
|
||||
}
|
||||
|
||||
|
||||
@@ -28,28 +28,28 @@
|
||||
package com.projectswg.common.intents;
|
||||
|
||||
import com.projectswg.common.control.Intent;
|
||||
import com.projectswg.lightspeed_frontend.data.ServerData;
|
||||
import com.projectswg.lightspeed_frontend.data.SharedServerData;
|
||||
|
||||
public class PrepareStarshipIntent extends Intent {
|
||||
|
||||
public static final String TYPE = "PrepareStarshipIntent";
|
||||
|
||||
private ServerData server;
|
||||
private SharedServerData server;
|
||||
|
||||
public PrepareStarshipIntent() {
|
||||
this(null);
|
||||
}
|
||||
|
||||
public PrepareStarshipIntent(ServerData server) {
|
||||
public PrepareStarshipIntent(SharedServerData server) {
|
||||
super(TYPE);
|
||||
setServer(server);
|
||||
}
|
||||
|
||||
public ServerData getServer() {
|
||||
public SharedServerData getServer() {
|
||||
return server;
|
||||
}
|
||||
|
||||
public void setServer(ServerData server) {
|
||||
public void setServer(SharedServerData server) {
|
||||
this.server = server;
|
||||
}
|
||||
|
||||
|
||||
@@ -31,20 +31,20 @@ import me.joshlarson.json.JSONObject;
|
||||
|
||||
import com.projectswg.common.network.packets.Packet;
|
||||
import com.projectswg.common.network.packets.PacketType;
|
||||
import com.projectswg.lightspeed_frontend.data.ServerData;
|
||||
import com.projectswg.lightspeed_frontend.data.SharedServerData;
|
||||
|
||||
public class PostCreateServerPacket extends Packet {
|
||||
|
||||
private final ServerData server;
|
||||
private final SharedServerData server;
|
||||
|
||||
public PostCreateServerPacket(JSONObject json) {
|
||||
super(json, PacketType.POST_CREATE_SERVER);
|
||||
server = new ServerData(json.getString("server_id"));
|
||||
server = new SharedServerData(json.getString("server_id"));
|
||||
server.setDirectory(json.getString("dir"));
|
||||
server.setJvmArguments(json.getString("jvm_arguments"));
|
||||
}
|
||||
|
||||
public ServerData getServer() {
|
||||
public SharedServerData getServer() {
|
||||
return server;
|
||||
}
|
||||
|
||||
|
||||
@@ -35,11 +35,11 @@ import me.joshlarson.json.JSONArray;
|
||||
import me.joshlarson.json.JSONObject;
|
||||
|
||||
import com.projectswg.common.network.packets.PacketType;
|
||||
import com.projectswg.lightspeed_frontend.data.BuildData;
|
||||
import com.projectswg.lightspeed_frontend.data.SharedBuildData;
|
||||
|
||||
public class ResponseBuildHistoryPacket extends ResponsePacket {
|
||||
|
||||
private final List<BuildData> buildHistory;
|
||||
private final List<SharedBuildData> buildHistory;
|
||||
private final String serverId;
|
||||
|
||||
public ResponseBuildHistoryPacket(JSONObject json) {
|
||||
@@ -50,7 +50,7 @@ public class ResponseBuildHistoryPacket extends ResponsePacket {
|
||||
for (Object o : buildHistoryArray) {
|
||||
if (o instanceof JSONObject) {
|
||||
JSONObject obj = (JSONObject) o;
|
||||
buildHistory.add(new BuildData(obj));
|
||||
buildHistory.add(new SharedBuildData(obj));
|
||||
if (obj.containsKey("server_id"))
|
||||
serverId = obj.getString("server_id");
|
||||
}
|
||||
@@ -58,7 +58,7 @@ public class ResponseBuildHistoryPacket extends ResponsePacket {
|
||||
this.serverId = serverId;
|
||||
}
|
||||
|
||||
private ResponseBuildHistoryPacket(JSONObject json, List<BuildData> buildHistory) {
|
||||
private ResponseBuildHistoryPacket(JSONObject json, List<SharedBuildData> buildHistory) {
|
||||
super(json, PacketType.RESPONSE_BUILD_HISTORY);
|
||||
this.buildHistory = buildHistory;
|
||||
if (!buildHistory.isEmpty())
|
||||
@@ -67,7 +67,7 @@ public class ResponseBuildHistoryPacket extends ResponsePacket {
|
||||
serverId = null;
|
||||
}
|
||||
|
||||
public List<BuildData> getBuildHistory() {
|
||||
public List<SharedBuildData> getBuildHistory() {
|
||||
return Collections.unmodifiableList(buildHistory);
|
||||
}
|
||||
|
||||
@@ -75,10 +75,10 @@ public class ResponseBuildHistoryPacket extends ResponsePacket {
|
||||
return serverId;
|
||||
}
|
||||
|
||||
public static ResponseBuildHistoryPacket create(long requestId, List<BuildData> buildHistory) {
|
||||
public static ResponseBuildHistoryPacket create(long requestId, List<SharedBuildData> buildHistory) {
|
||||
JSONObject json = ResponsePacket.createResponsePacketJson(PacketType.RESPONSE_BUILD_HISTORY, requestId);
|
||||
JSONArray buildHistoryArray = new JSONArray();
|
||||
for (BuildData buildinfo : buildHistory) {
|
||||
for (SharedBuildData buildinfo : buildHistory) {
|
||||
buildHistoryArray.add(buildinfo.createJSON());
|
||||
}
|
||||
json.put("build_history", buildHistoryArray);
|
||||
|
||||
+7
-7
@@ -35,11 +35,11 @@ import me.joshlarson.json.JSONArray;
|
||||
import me.joshlarson.json.JSONObject;
|
||||
|
||||
import com.projectswg.common.network.packets.PacketType;
|
||||
import com.projectswg.lightspeed_frontend.data.DeploymentData;
|
||||
import com.projectswg.lightspeed_frontend.data.SharedDeploymentData;
|
||||
|
||||
public class ResponseDeploymentHistoryPacket extends ResponsePacket {
|
||||
|
||||
private final List<DeploymentData> deploymentHistory;
|
||||
private final List<SharedDeploymentData> deploymentHistory;
|
||||
private final long buildId;
|
||||
private final String serverId;
|
||||
|
||||
@@ -52,7 +52,7 @@ public class ResponseDeploymentHistoryPacket extends ResponsePacket {
|
||||
for (Object o : buildHistoryArray) {
|
||||
if (o instanceof JSONObject) {
|
||||
JSONObject obj = (JSONObject) o;
|
||||
deploymentHistory.add(new DeploymentData(obj));
|
||||
deploymentHistory.add(new SharedDeploymentData(obj));
|
||||
if (obj.containsKey("build_id"))
|
||||
buildId = obj.getLong("build_id");
|
||||
if (obj.containsKey("server_id"))
|
||||
@@ -63,7 +63,7 @@ public class ResponseDeploymentHistoryPacket extends ResponsePacket {
|
||||
this.serverId = serverId;
|
||||
}
|
||||
|
||||
private ResponseDeploymentHistoryPacket(JSONObject json, List<DeploymentData> deploymentHistory) {
|
||||
private ResponseDeploymentHistoryPacket(JSONObject json, List<SharedDeploymentData> deploymentHistory) {
|
||||
super(json, PacketType.RESPONSE_DEPLOYMENT_HISTORY);
|
||||
this.deploymentHistory = deploymentHistory;
|
||||
if (!deploymentHistory.isEmpty()) {
|
||||
@@ -75,7 +75,7 @@ public class ResponseDeploymentHistoryPacket extends ResponsePacket {
|
||||
}
|
||||
}
|
||||
|
||||
public List<DeploymentData> getDeploymentHistory() {
|
||||
public List<SharedDeploymentData> getDeploymentHistory() {
|
||||
return Collections.unmodifiableList(deploymentHistory);
|
||||
}
|
||||
|
||||
@@ -87,10 +87,10 @@ public class ResponseDeploymentHistoryPacket extends ResponsePacket {
|
||||
return serverId;
|
||||
}
|
||||
|
||||
public static ResponseDeploymentHistoryPacket create(long requestId, List<DeploymentData> deploymentHistory) {
|
||||
public static ResponseDeploymentHistoryPacket create(long requestId, List<SharedDeploymentData> deploymentHistory) {
|
||||
JSONObject json = ResponsePacket.createResponsePacketJson(PacketType.RESPONSE_DEPLOYMENT_HISTORY, requestId);
|
||||
JSONArray deploymentHistoryArray = new JSONArray();
|
||||
for (DeploymentData info : deploymentHistory) {
|
||||
for (SharedDeploymentData info : deploymentHistory) {
|
||||
deploymentHistoryArray.add(info.createJSON());
|
||||
}
|
||||
json.put("deployment_history", deploymentHistoryArray);
|
||||
|
||||
+7
-7
@@ -35,11 +35,11 @@ import me.joshlarson.json.JSONArray;
|
||||
import me.joshlarson.json.JSONObject;
|
||||
|
||||
import com.projectswg.common.network.packets.PacketType;
|
||||
import com.projectswg.lightspeed_frontend.data.DeploymentData;
|
||||
import com.projectswg.lightspeed_frontend.data.SharedDeploymentData;
|
||||
|
||||
public class ResponseDeploymentStatusPacket extends ResponsePacket {
|
||||
|
||||
private final List<DeploymentData> deployments;
|
||||
private final List<SharedDeploymentData> deployments;
|
||||
|
||||
public ResponseDeploymentStatusPacket(JSONObject json) {
|
||||
super(json, PacketType.RESPONSE_DEPLOYMENT_STATUS);
|
||||
@@ -47,24 +47,24 @@ public class ResponseDeploymentStatusPacket extends ResponsePacket {
|
||||
JSONArray deploymentssArray = json.getArray("deployments");
|
||||
for (Object o : deploymentssArray) {
|
||||
if (o instanceof JSONObject) {
|
||||
deployments.add(new DeploymentData((JSONObject) o));
|
||||
deployments.add(new SharedDeploymentData((JSONObject) o));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private ResponseDeploymentStatusPacket(JSONObject json, List<DeploymentData> deployments) {
|
||||
private ResponseDeploymentStatusPacket(JSONObject json, List<SharedDeploymentData> deployments) {
|
||||
super(json, PacketType.RESPONSE_DEPLOYMENT_STATUS);
|
||||
this.deployments = deployments;
|
||||
}
|
||||
|
||||
public List<DeploymentData> getDeployments() {
|
||||
public List<SharedDeploymentData> getDeployments() {
|
||||
return Collections.unmodifiableList(deployments);
|
||||
}
|
||||
|
||||
public static ResponseDeploymentStatusPacket create(long requestId, List<DeploymentData> deployments) {
|
||||
public static ResponseDeploymentStatusPacket create(long requestId, List<SharedDeploymentData> deployments) {
|
||||
JSONObject json = ResponsePacket.createResponsePacketJson(PacketType.RESPONSE_DEPLOYMENT_STATUS, requestId);
|
||||
JSONArray deploymentsArray = new JSONArray();
|
||||
for (DeploymentData info : deployments) {
|
||||
for (SharedDeploymentData info : deployments) {
|
||||
deploymentsArray.add(info.createJSON());
|
||||
}
|
||||
json.put("deployments", deploymentsArray);
|
||||
|
||||
@@ -53,15 +53,15 @@ import com.projectswg.common.network.packets.request.RequestPacket;
|
||||
import com.projectswg.common.network.packets.response.ResponseDeploymentHistoryPacket;
|
||||
import com.projectswg.common.network.packets.response.ResponseDeploymentStatusPacket;
|
||||
import com.projectswg.common.utilities.TimeUtilities;
|
||||
import com.projectswg.lightspeed.deployment.Deployment;
|
||||
import com.projectswg.lightspeed_frontend.data.BuildData;
|
||||
import com.projectswg.lightspeed_frontend.data.DeploymentData;
|
||||
import com.projectswg.lightspeed_frontend.data.ServerData;
|
||||
import com.projectswg.lightspeed.deployment.ServerDeploymentData;
|
||||
import com.projectswg.lightspeed_frontend.data.SharedBuildData;
|
||||
import com.projectswg.lightspeed_frontend.data.SharedDeploymentData;
|
||||
import com.projectswg.lightspeed_frontend.data.SharedServerData;
|
||||
|
||||
public class DeploymentService extends Service {
|
||||
|
||||
private final AtomicLong deploymentId;
|
||||
private final Map<String, Deployment> deployments;
|
||||
private final Map<String, ServerDeploymentData> deployments;
|
||||
|
||||
public DeploymentService() {
|
||||
deploymentId = new AtomicLong(0);
|
||||
@@ -77,10 +77,12 @@ public class DeploymentService extends Service {
|
||||
ResultSet set = db.executeQuery("SELECT MAX(id) FROM deployments");
|
||||
if (set.next())
|
||||
deploymentId.set(set.getLong(1));
|
||||
for (ServerData server : getBackendData().getServerList()) {
|
||||
DeploymentData last = server.getLastDeployment();
|
||||
Deployment d = new Deployment(last);
|
||||
deployments.put(server.getName(), d);
|
||||
for (SharedServerData server : getBackendData().getServerList()) {
|
||||
SharedDeploymentData last = server.getLastDeployment();
|
||||
if (last != null) {
|
||||
ServerDeploymentData d = new ServerDeploymentData(last);
|
||||
deployments.put(server.getName(), d);
|
||||
}
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
@@ -91,7 +93,7 @@ public class DeploymentService extends Service {
|
||||
@Override
|
||||
public boolean terminate() {
|
||||
synchronized (deployments) {
|
||||
for (Deployment deployment : deployments.values()) {
|
||||
for (ServerDeploymentData deployment : deployments.values()) {
|
||||
if (deployment.getProcess() != null)
|
||||
deployment.getProcess().stop();
|
||||
}
|
||||
@@ -103,9 +105,9 @@ public class DeploymentService extends Service {
|
||||
@Override
|
||||
public void onIntentReceived(Intent i) {
|
||||
if (i instanceof LaunchStarshipIntent) {
|
||||
BuildData build = ((LaunchStarshipIntent) i).getBuild();
|
||||
SharedBuildData build = ((LaunchStarshipIntent) i).getBuild();
|
||||
Log.i(this, "Deploying %s... JAR: %s", build.getServer().getName(), build.getJar());
|
||||
Deployment deployment = new Deployment(new DeploymentData(deploymentId.incrementAndGet(), build));
|
||||
ServerDeploymentData deployment = new ServerDeploymentData(new SharedDeploymentData(deploymentId.incrementAndGet(), build));
|
||||
launch(deployment);
|
||||
} else if (i instanceof InboundPacketIntent) {
|
||||
processInboundPacketIntent(((InboundPacketIntent) i).getAddress(), ((InboundPacketIntent) i).getPacket());
|
||||
@@ -124,7 +126,7 @@ public class DeploymentService extends Service {
|
||||
|
||||
private void processStopDeployment(PostStopDeployPacket p) {
|
||||
synchronized (deployments) {
|
||||
Deployment d = deployments.get(p.getServerId());
|
||||
ServerDeploymentData d = deployments.get(p.getServerId());
|
||||
if (d != null) {
|
||||
if (d.getProcess() != null)
|
||||
d.getProcess().stop();
|
||||
@@ -133,21 +135,21 @@ public class DeploymentService extends Service {
|
||||
}
|
||||
|
||||
private void processRequestDeploymentStatus(InetSocketAddress address, long requestId) {
|
||||
List<DeploymentData> deployments = new ArrayList<>(this.deployments.size());
|
||||
List<SharedDeploymentData> deployments = new ArrayList<>(this.deployments.size());
|
||||
synchronized (this.deployments) {
|
||||
for (Deployment deployment : this.deployments.values()) {
|
||||
deployments.add(new DeploymentData(deployment.getId(), deployment.getBuild()));
|
||||
for (ServerDeploymentData deployment : this.deployments.values()) {
|
||||
deployments.add(new SharedDeploymentData(deployment.getId(), deployment.getBuild()));
|
||||
}
|
||||
}
|
||||
new OutboundPacketIntent(address, ResponseDeploymentStatusPacket.create(requestId, deployments)).broadcast();
|
||||
}
|
||||
|
||||
private void processRequestDeploymentHistory(InetSocketAddress address, RequestDeploymentHistoryPacket req) {
|
||||
List<DeploymentData> deployments = getBackendData().getBuild(req.getBuildId()).getDeployments();
|
||||
List<SharedDeploymentData> deployments = getBackendData().getBuild(req.getBuildId()).getDeployments();
|
||||
synchronized (this.deployments) {
|
||||
for (Deployment deployment : this.deployments.values()) {
|
||||
for (ServerDeploymentData deployment : this.deployments.values()) {
|
||||
if (deployment.getBuild().getId() == req.getBuildId()) {
|
||||
DeploymentData data = new DeploymentData(deployment.getId(), deployment.getBuild());
|
||||
SharedDeploymentData data = new SharedDeploymentData(deployment.getId(), deployment.getBuild());
|
||||
data.setStartTime(deployment.getStartTime());
|
||||
data.setEndTime(deployment.getEndTime());
|
||||
deployments.add(data);
|
||||
@@ -158,13 +160,13 @@ public class DeploymentService extends Service {
|
||||
}
|
||||
|
||||
private void launchStarship(long buildId) {
|
||||
BuildData build = getBackendData().getBuild(buildId);
|
||||
SharedBuildData build = getBackendData().getBuild(buildId);
|
||||
if (!launchStarshipChecks(build))
|
||||
return;
|
||||
new LaunchStarshipIntent(build).broadcast();
|
||||
}
|
||||
|
||||
private boolean launchStarshipChecks(BuildData build) {
|
||||
private boolean launchStarshipChecks(SharedBuildData build) {
|
||||
if (build == null) {
|
||||
Log.e(this, "Unable to launch - no build found!");
|
||||
return false;
|
||||
@@ -184,7 +186,7 @@ public class DeploymentService extends Service {
|
||||
return true;
|
||||
}
|
||||
|
||||
private void launch(Deployment deployment) {
|
||||
private void launch(ServerDeploymentData deployment) {
|
||||
String serverId = deployment.getServer().getName();
|
||||
File jar = deployment.getBuild().getJar();
|
||||
if (jar == null) {
|
||||
@@ -198,7 +200,7 @@ public class DeploymentService extends Service {
|
||||
StarshipProcess process = StarshipProcess.create(jar, new File(deployment.getServer().getDirectory()), deployment.getServer().getJvmArguments(), "");
|
||||
deployment.setProcess(process);
|
||||
synchronized (deployments) {
|
||||
Deployment old = deployments.put(serverId, deployment);
|
||||
ServerDeploymentData old = deployments.put(serverId, deployment);
|
||||
if (old != null && old.isAlive()) {
|
||||
Log.e(this, "Unable to deploy %s. Already deploying!", serverId);
|
||||
deployments.put(serverId, old);
|
||||
@@ -217,11 +219,11 @@ public class DeploymentService extends Service {
|
||||
}, "deployment-"+serverId+"-supervisor").start();
|
||||
}
|
||||
|
||||
private void onDeploymentStarted(Deployment deployment) {
|
||||
private void onDeploymentStarted(ServerDeploymentData deployment) {
|
||||
deployment.setStartTime(TimeUtilities.getTime());
|
||||
}
|
||||
|
||||
private void onDeploymentEnded(Deployment deployment) {
|
||||
private void onDeploymentEnded(ServerDeploymentData deployment) {
|
||||
deployment.setEndTime(TimeUtilities.getTime());
|
||||
getBackendData().insertDeployment(deployment.getDeploymentData());
|
||||
Log.i(this, "%s has finished deploying after %.2f minutes", deployment.getServer().getName(), (deployment.getEndTime()-deployment.getStartTime())/60E3);
|
||||
@@ -229,7 +231,7 @@ public class DeploymentService extends Service {
|
||||
|
||||
private boolean isDeploying(String serverId) {
|
||||
synchronized (deployments) {
|
||||
Deployment deployment = deployments.get(serverId);
|
||||
ServerDeploymentData deployment = deployments.get(serverId);
|
||||
return deployment != null && deployment.isAlive();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -58,15 +58,15 @@ import com.projectswg.common.network.packets.request.RequestBuildHistoryPacket;
|
||||
import com.projectswg.common.network.packets.request.RequestPacket;
|
||||
import com.projectswg.common.network.packets.response.ResponseBuildHistoryPacket;
|
||||
import com.projectswg.common.network.packets.response.ResponseServerListPacket;
|
||||
import com.projectswg.lightspeed.build.InstallationDetails.InstallationCallback;
|
||||
import com.projectswg.lightspeed_frontend.data.BuildData;
|
||||
import com.projectswg.lightspeed_frontend.data.ServerData;
|
||||
import com.projectswg.lightspeed.build.ServerBuildData.InstallationCallback;
|
||||
import com.projectswg.lightspeed_frontend.data.SharedBuildData;
|
||||
import com.projectswg.lightspeed_frontend.data.SharedServerData;
|
||||
|
||||
public class BuildService extends Service {
|
||||
|
||||
private final MavenInterface maven;
|
||||
private final AtomicLong buildId;
|
||||
private final Map <String, InstallationDetails> inprogress;
|
||||
private final Map <String, ServerBuildData> inprogress;
|
||||
|
||||
public BuildService() {
|
||||
maven = new MavenInterface(new File(getConfig(ConfigFile.LIGHTSPEED).getString("MAVEN", "/usr/bin/mvn")));
|
||||
@@ -98,13 +98,13 @@ public class BuildService extends Service {
|
||||
|
||||
private void onPrepareStarshipIntent(PrepareStarshipIntent psi) {
|
||||
Log.i(this, "Building %s...", psi.getServer().getName());
|
||||
InstallationDetails installation = maven.createJar(psi.getServer().getDirectory(), new InstallationCallback() {
|
||||
ServerBuildData installation = maven.createJar(psi.getServer().getDirectory(), new InstallationCallback() {
|
||||
public void onStateChanged(InstallationState oldState, InstallationState newState) { }
|
||||
public void onCompleted() { BuildService.this.onCompleted(psi.getServer().getName()); }
|
||||
public void onCancelled() { BuildService.this.onCancelled(psi.getServer().getName()); }
|
||||
});
|
||||
synchronized (inprogress) {
|
||||
InstallationDetails old = inprogress.put(psi.getServer().getName(), installation);
|
||||
ServerBuildData old = inprogress.put(psi.getServer().getName(), installation);
|
||||
if (old != null)
|
||||
old.cancel();
|
||||
}
|
||||
@@ -127,21 +127,21 @@ public class BuildService extends Service {
|
||||
}
|
||||
|
||||
private void processBuild(PostBuildPacket p) {
|
||||
ServerData server = getBackendData().getServer(p.getServerId());
|
||||
SharedServerData server = getBackendData().getServer(p.getServerId());
|
||||
if (server != null)
|
||||
new PrepareStarshipIntent(server).broadcast();
|
||||
}
|
||||
|
||||
private void processPostStopBuild(PostStopBuildPacket p) {
|
||||
synchronized (inprogress) {
|
||||
InstallationDetails installation = inprogress.get(p.getServerId());
|
||||
ServerBuildData installation = inprogress.get(p.getServerId());
|
||||
if (installation != null)
|
||||
installation.cancel();
|
||||
}
|
||||
}
|
||||
|
||||
private void processPostCreateServer(PostCreateServerPacket p) {
|
||||
ServerData server = p.getServer();
|
||||
SharedServerData server = p.getServer();
|
||||
getBackendData().insertServer(p.getServer());
|
||||
Log.i(this, "Creating server: id=%s, directory=%s, jvm_arguments=%s", server.getName(), server.getDirectory(), server.getJvmArguments());
|
||||
}
|
||||
@@ -152,8 +152,8 @@ public class BuildService extends Service {
|
||||
}
|
||||
|
||||
private void sendBuildHistoryResponse(InetSocketAddress address, long requestId, String serverId) {
|
||||
ServerData server = getBackendData().getServer(serverId);
|
||||
List<BuildData> builds;
|
||||
SharedServerData server = getBackendData().getServer(serverId);
|
||||
List<SharedBuildData> builds;
|
||||
if (server == null)
|
||||
builds = new ArrayList<>();
|
||||
else
|
||||
@@ -162,15 +162,15 @@ public class BuildService extends Service {
|
||||
}
|
||||
|
||||
private void sendServerListResponse(InetSocketAddress address, long requestId) {
|
||||
List<ServerData> servers = getBackendData().getServerList();
|
||||
List<SharedServerData> servers = getBackendData().getServerList();
|
||||
List<String> serverStrings = new ArrayList<>(servers.size());
|
||||
for (ServerData server : servers)
|
||||
for (SharedServerData server : servers)
|
||||
serverStrings.add(server.getName());
|
||||
new OutboundPacketIntent(address, ResponseServerListPacket.create(requestId, serverStrings)).broadcast();
|
||||
}
|
||||
|
||||
private void onCompleted(String serverId) {
|
||||
InstallationDetails installation;
|
||||
ServerBuildData installation;
|
||||
synchronized (inprogress) {
|
||||
installation = inprogress.remove(serverId);
|
||||
}
|
||||
@@ -182,22 +182,22 @@ public class BuildService extends Service {
|
||||
}
|
||||
|
||||
private void onCancelled(String serverId) {
|
||||
InstallationDetails installation;
|
||||
ServerBuildData installation;
|
||||
synchronized (inprogress) {
|
||||
installation = inprogress.remove(serverId);
|
||||
}
|
||||
if (installation != null) {
|
||||
Log.i(this, "Build cancelled: %s", serverId);
|
||||
ServerData server = getBackendData().getServer(serverId);
|
||||
SharedServerData server = getBackendData().getServer(serverId);
|
||||
if (server == null)
|
||||
return;
|
||||
getBackendData().insertBuild(new BuildData(buildId.incrementAndGet(), server, installation, null));
|
||||
getBackendData().insertBuild(new SharedBuildData(buildId.incrementAndGet(), server, installation, null));
|
||||
}
|
||||
}
|
||||
|
||||
private void processBuildCompleted(long id, String serverId, InstallationDetails installation) {
|
||||
private void processBuildCompleted(long id, String serverId, ServerBuildData installation) {
|
||||
try (RelationalDatabase db = RelationalServerFactory.getServerDatabase("lightspeed.db")) {
|
||||
ServerData server = getBackendData().getServer(serverId);
|
||||
SharedServerData server = getBackendData().getServer(serverId);
|
||||
if (server == null) {
|
||||
Log.e(this, "Build Success - error while retrieving server information. Server: %s", serverId);
|
||||
return;
|
||||
@@ -207,7 +207,7 @@ public class BuildService extends Service {
|
||||
Files.copy(installation.getJar().toPath(), jar.toPath());
|
||||
else
|
||||
jar = null;
|
||||
BuildData build = new BuildData(buildId.incrementAndGet(), server, installation, jar);
|
||||
SharedBuildData build = new SharedBuildData(buildId.incrementAndGet(), server, installation, jar);
|
||||
getBackendData().insertBuild(build);
|
||||
processPostBuild(build);
|
||||
} catch (IOException e) {
|
||||
@@ -215,7 +215,7 @@ public class BuildService extends Service {
|
||||
}
|
||||
}
|
||||
|
||||
private void processPostBuild(BuildData build) {
|
||||
private void processPostBuild(SharedBuildData build) {
|
||||
if (build.isBuildSuccess() && build.isTestSuccess()) {
|
||||
Log.i(this, "Build Success! Server: %s", build.getServer().getName());
|
||||
new LaunchStarshipIntent(build).broadcast();
|
||||
|
||||
@@ -34,7 +34,7 @@ import java.io.InputStreamReader;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import com.projectswg.lightspeed.build.InstallationDetails.InstallationCallback;
|
||||
import com.projectswg.lightspeed.build.ServerBuildData.InstallationCallback;
|
||||
|
||||
public class MavenInterface {
|
||||
|
||||
@@ -62,8 +62,8 @@ public class MavenInterface {
|
||||
return offline;
|
||||
}
|
||||
|
||||
public InstallationDetails createJar(String repo, InstallationCallback callback) {
|
||||
return InstallationDetails.install(maven, new File(repo), offline, callback);
|
||||
public ServerBuildData createJar(String repo, InstallationCallback callback) {
|
||||
return ServerBuildData.install(maven, new File(repo), offline, callback);
|
||||
}
|
||||
|
||||
private boolean initializeMaven() {
|
||||
|
||||
+4
-4
@@ -38,7 +38,7 @@ import java.util.regex.Pattern;
|
||||
import com.projectswg.common.data.TestDetails;
|
||||
import com.projectswg.common.utilities.TimeUtilities;
|
||||
|
||||
public class InstallationDetails {
|
||||
public class ServerBuildData {
|
||||
|
||||
private final AtomicBoolean cancelBuild;
|
||||
private final File directory;
|
||||
@@ -55,7 +55,7 @@ public class InstallationDetails {
|
||||
private boolean buildSuccess;
|
||||
private boolean testSuccess;
|
||||
|
||||
private InstallationDetails(File directory, boolean offline, InstallationCallback callback) {
|
||||
private ServerBuildData(File directory, boolean offline, InstallationCallback callback) {
|
||||
this.directory = directory;
|
||||
this.offline = offline;
|
||||
this.cancelBuild = new AtomicBoolean(false);
|
||||
@@ -64,8 +64,8 @@ public class InstallationDetails {
|
||||
this.state = InstallationState.IDLE;
|
||||
}
|
||||
|
||||
public static InstallationDetails install(File maven, File directory, boolean offline, InstallationCallback callback) {
|
||||
InstallationDetails details = new InstallationDetails(directory, offline, callback);
|
||||
public static ServerBuildData install(File maven, File directory, boolean offline, InstallationCallback callback) {
|
||||
ServerBuildData details = new ServerBuildData(directory, offline, callback);
|
||||
Thread t = new Thread(() -> details.install(maven));
|
||||
t.setName("InstallationDetails-install(dir="+directory.getAbsolutePath()+")");
|
||||
t.start();
|
||||
+9
-9
@@ -28,23 +28,23 @@
|
||||
package com.projectswg.lightspeed.deployment;
|
||||
|
||||
import com.projectswg.lightspeed.StarshipProcess;
|
||||
import com.projectswg.lightspeed_frontend.data.BuildData;
|
||||
import com.projectswg.lightspeed_frontend.data.DeploymentData;
|
||||
import com.projectswg.lightspeed_frontend.data.ServerData;
|
||||
import com.projectswg.lightspeed_frontend.data.SharedBuildData;
|
||||
import com.projectswg.lightspeed_frontend.data.SharedDeploymentData;
|
||||
import com.projectswg.lightspeed_frontend.data.SharedServerData;
|
||||
|
||||
public class Deployment {
|
||||
public class ServerDeploymentData {
|
||||
|
||||
private final DeploymentData data;
|
||||
private final SharedDeploymentData data;
|
||||
private final PSWGData pswgData;
|
||||
private StarshipProcess process;
|
||||
|
||||
public Deployment(DeploymentData data) {
|
||||
public ServerDeploymentData(SharedDeploymentData data) {
|
||||
this.data = data;
|
||||
this.process = null;
|
||||
this.pswgData = new PSWGData();
|
||||
}
|
||||
|
||||
public DeploymentData getDeploymentData() {
|
||||
public SharedDeploymentData getDeploymentData() {
|
||||
return data;
|
||||
}
|
||||
|
||||
@@ -52,11 +52,11 @@ public class Deployment {
|
||||
return data.getId();
|
||||
}
|
||||
|
||||
public ServerData getServer() {
|
||||
public SharedServerData getServer() {
|
||||
return data.getBuild().getServer();
|
||||
}
|
||||
|
||||
public BuildData getBuild() {
|
||||
public SharedBuildData getBuild() {
|
||||
return data.getBuild();
|
||||
}
|
||||
|
||||
@@ -47,9 +47,9 @@ import com.projectswg.common.network.packets.response.ResponseServerListPacket;
|
||||
import com.projectswg.lightspeed_frontend.FrontendData.FrontendDataType;
|
||||
import com.projectswg.lightspeed_frontend.communication.FrontendCommunication;
|
||||
import com.projectswg.lightspeed_frontend.communication.FrontendLightspeedSession.LightspeedSessionCallback;
|
||||
import com.projectswg.lightspeed_frontend.data.BuildData;
|
||||
import com.projectswg.lightspeed_frontend.data.DeploymentData;
|
||||
import com.projectswg.lightspeed_frontend.data.ServerData;
|
||||
import com.projectswg.lightspeed_frontend.data.SharedBuildData;
|
||||
import com.projectswg.lightspeed_frontend.data.SharedDeploymentData;
|
||||
import com.projectswg.lightspeed_frontend.data.SharedServerData;
|
||||
|
||||
public class Frontend {
|
||||
|
||||
@@ -124,10 +124,10 @@ public class Frontend {
|
||||
public void requestCompleteLoad() {
|
||||
AtomicInteger requests = new AtomicInteger(1);
|
||||
send(RequestServerListPacket.create(requestId.incrementAndGet()), (response) -> {
|
||||
for (ServerData server : data.getServers()) {
|
||||
for (SharedServerData server : data.getServers()) {
|
||||
requests.incrementAndGet();
|
||||
loadBuildHistory(server.getName(), (buildResponse) -> {
|
||||
for (BuildData build : server.getBuildData()) {
|
||||
for (SharedBuildData build : server.getBuildData()) {
|
||||
requests.incrementAndGet();
|
||||
loadDeploymentHistory(build.getId(), (deploymentResponse) -> {
|
||||
if (requests.decrementAndGet() == 0)
|
||||
@@ -163,13 +163,13 @@ public class Frontend {
|
||||
}
|
||||
|
||||
private void processBuildHistory(ResponseBuildHistoryPacket p) {
|
||||
List<BuildData> buildHistory = p.getBuildHistory();
|
||||
List<SharedBuildData> buildHistory = p.getBuildHistory();
|
||||
if (buildHistory.isEmpty())
|
||||
return;
|
||||
ServerData server = data.getServer(p.getServerId());
|
||||
SharedServerData server = data.getServer(p.getServerId());
|
||||
if (server == null)
|
||||
return;
|
||||
for (BuildData build : buildHistory) {
|
||||
for (SharedBuildData build : buildHistory) {
|
||||
build.setServer(server);
|
||||
server.addBuild(build);
|
||||
}
|
||||
@@ -177,14 +177,14 @@ public class Frontend {
|
||||
}
|
||||
|
||||
private void processDeploymentHistory(ResponseDeploymentHistoryPacket p) {
|
||||
List<DeploymentData> deploymentHistory = p.getDeploymentHistory();
|
||||
ServerData server = data.getServer(p.getServerId());
|
||||
List<SharedDeploymentData> deploymentHistory = p.getDeploymentHistory();
|
||||
SharedServerData server = data.getServer(p.getServerId());
|
||||
if (server == null)
|
||||
return;
|
||||
BuildData build = server.getBuildData(p.getBuildId());
|
||||
SharedBuildData build = server.getBuildData(p.getBuildId());
|
||||
if (build == null)
|
||||
return;
|
||||
for (DeploymentData deployment : deploymentHistory) {
|
||||
for (SharedDeploymentData deployment : deploymentHistory) {
|
||||
deployment.setBuild(build);
|
||||
build.addDeployment(deployment);
|
||||
}
|
||||
|
||||
@@ -33,13 +33,13 @@ import java.util.List;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
import com.projectswg.common.callback.CallbackManager;
|
||||
import com.projectswg.lightspeed_frontend.data.ServerData;
|
||||
import com.projectswg.lightspeed_frontend.data.SharedServerData;
|
||||
|
||||
public class FrontendData {
|
||||
|
||||
private final CallbackManager<FrontendDataUpdateCallback> updateCallbackManager;
|
||||
private final CallbackManager<FrontendConnectionCallback> connectionCallbackManager;
|
||||
private List<ServerData> servers;
|
||||
private List<SharedServerData> servers;
|
||||
private AtomicBoolean connected;
|
||||
|
||||
public FrontendData() {
|
||||
@@ -74,7 +74,7 @@ public class FrontendData {
|
||||
|
||||
public void setServers(List<String> servers) {
|
||||
synchronized (this.servers) {
|
||||
for (ServerData server : new ArrayList<>(this.servers)) {
|
||||
for (SharedServerData server : new ArrayList<>(this.servers)) {
|
||||
if (!servers.contains(server.getName())) {
|
||||
this.servers.remove(server);
|
||||
} else {
|
||||
@@ -82,7 +82,7 @@ public class FrontendData {
|
||||
}
|
||||
}
|
||||
for (String server : servers) {
|
||||
this.servers.add(new ServerData(server));
|
||||
this.servers.add(new SharedServerData(server));
|
||||
}
|
||||
}
|
||||
notifyDataUpdated(FrontendDataType.SERVER_LIST);
|
||||
@@ -93,13 +93,13 @@ public class FrontendData {
|
||||
notifyConnectionUpdated(connected);
|
||||
}
|
||||
|
||||
public List<ServerData> getServers() {
|
||||
public List<SharedServerData> getServers() {
|
||||
return Collections.unmodifiableList(servers);
|
||||
}
|
||||
|
||||
public ServerData getServer(String serverId) {
|
||||
public SharedServerData getServer(String serverId) {
|
||||
synchronized (servers) {
|
||||
for (ServerData server : servers) {
|
||||
for (SharedServerData server : servers) {
|
||||
if (server.getName().equals(serverId))
|
||||
return server;
|
||||
}
|
||||
|
||||
@@ -52,8 +52,8 @@ import com.projectswg.common.network.packets.response.ResponseDeploymentStatusPa
|
||||
import com.projectswg.common.network.packets.response.ResponseServerListPacket;
|
||||
import com.projectswg.lightspeed_frontend.communication.FrontendCommunication;
|
||||
import com.projectswg.lightspeed_frontend.communication.FrontendLightspeedSession.LightspeedSessionCallback;
|
||||
import com.projectswg.lightspeed_frontend.data.BuildData;
|
||||
import com.projectswg.lightspeed_frontend.data.DeploymentData;
|
||||
import com.projectswg.lightspeed_frontend.data.SharedBuildData;
|
||||
import com.projectswg.lightspeed_frontend.data.SharedDeploymentData;
|
||||
|
||||
public class LightspeedFrontendText implements LightspeedSessionCallback {
|
||||
|
||||
@@ -268,17 +268,17 @@ public class LightspeedFrontendText implements LightspeedSessionCallback {
|
||||
Log.i(this, " " + server);
|
||||
} else if (p instanceof ResponseBuildHistoryPacket) {
|
||||
Log.i(this, "Build History:");
|
||||
for (BuildData build : ((ResponseBuildHistoryPacket) p).getBuildHistory()) {
|
||||
for (SharedBuildData build : ((ResponseBuildHistoryPacket) p).getBuildHistory()) {
|
||||
Log.i(this, " " + build);
|
||||
}
|
||||
} else if (p instanceof ResponseDeploymentStatusPacket) {
|
||||
Log.i(this, "Deployments:");
|
||||
for (DeploymentData deployment : ((ResponseDeploymentStatusPacket) p).getDeployments()) {
|
||||
for (SharedDeploymentData deployment : ((ResponseDeploymentStatusPacket) p).getDeployments()) {
|
||||
Log.i(this, " " + deployment);
|
||||
}
|
||||
} else if (p instanceof ResponseDeploymentHistoryPacket) {
|
||||
Log.i(this, "Deployments:");
|
||||
for (DeploymentData deployment : ((ResponseDeploymentHistoryPacket) p).getDeploymentHistory()) {
|
||||
for (SharedDeploymentData deployment : ((ResponseDeploymentHistoryPacket) p).getDeploymentHistory()) {
|
||||
Log.i(this, " " + deployment);
|
||||
}
|
||||
} else {
|
||||
|
||||
+15
-15
@@ -37,17 +37,17 @@ import me.joshlarson.json.JSONObject;
|
||||
|
||||
import com.projectswg.common.data.TestDetails;
|
||||
import com.projectswg.common.utilities.TimeUtilities;
|
||||
import com.projectswg.lightspeed.build.InstallationDetails;
|
||||
import com.projectswg.lightspeed.build.ServerBuildData;
|
||||
import com.projectswg.lightspeed.build.InstallationState;
|
||||
|
||||
public class BuildData {
|
||||
public class SharedBuildData {
|
||||
|
||||
private static final TestDetails DEFAULT_TEST_DETAILS = new TestDetails(0, 0, 0, 0);
|
||||
|
||||
private final long id;
|
||||
private final Map<Long, DeploymentData> deployments;
|
||||
private ServerData server;
|
||||
private DeploymentData lastDeployment;
|
||||
private final Map<Long, SharedDeploymentData> deployments;
|
||||
private SharedServerData server;
|
||||
private SharedDeploymentData lastDeployment;
|
||||
private long time;
|
||||
private String buildString;
|
||||
private String testString;
|
||||
@@ -59,7 +59,7 @@ public class BuildData {
|
||||
private TestDetails testDetails;
|
||||
private File jar;
|
||||
|
||||
public BuildData(long id, ServerData server) {
|
||||
public SharedBuildData(long id, SharedServerData server) {
|
||||
this.id = id;
|
||||
this.server = server;
|
||||
this.deployments = new HashMap<>();
|
||||
@@ -76,7 +76,7 @@ public class BuildData {
|
||||
this.jar = null;
|
||||
}
|
||||
|
||||
public BuildData(long id, ServerData server, InstallationDetails installation, File jar) {
|
||||
public SharedBuildData(long id, SharedServerData server, ServerBuildData installation, File jar) {
|
||||
this(id, server);
|
||||
this.buildString = installation.getBuildString();
|
||||
this.testString = installation.getTestString();
|
||||
@@ -90,7 +90,7 @@ public class BuildData {
|
||||
this.jar = jar;
|
||||
}
|
||||
|
||||
public BuildData(JSONObject json) {
|
||||
public SharedBuildData(JSONObject json) {
|
||||
this(json.getLong("id"), null);
|
||||
this.buildString = json.getString("build_string");
|
||||
this.testString = json.getString("test_string");
|
||||
@@ -126,17 +126,17 @@ public class BuildData {
|
||||
return id;
|
||||
}
|
||||
|
||||
public ServerData getServer() {
|
||||
public SharedServerData getServer() {
|
||||
return server;
|
||||
}
|
||||
|
||||
public List<DeploymentData> getDeployments() {
|
||||
public List<SharedDeploymentData> getDeployments() {
|
||||
synchronized (deployments) {
|
||||
return new ArrayList<>(deployments.values());
|
||||
}
|
||||
}
|
||||
|
||||
public DeploymentData getLastDeployment() {
|
||||
public SharedDeploymentData getLastDeployment() {
|
||||
return lastDeployment;
|
||||
}
|
||||
|
||||
@@ -184,7 +184,7 @@ public class BuildData {
|
||||
this.time = time;
|
||||
}
|
||||
|
||||
public void addDeployment(DeploymentData deployment) {
|
||||
public void addDeployment(SharedDeploymentData deployment) {
|
||||
synchronized (deployments) {
|
||||
deployments.put(deployment.getId(), deployment);
|
||||
if (lastDeployment == null || deployment.getId() > lastDeployment.getId())
|
||||
@@ -203,7 +203,7 @@ public class BuildData {
|
||||
server.onDeploymentsChanged();
|
||||
}
|
||||
|
||||
public void setServer(ServerData server) {
|
||||
public void setServer(SharedServerData server) {
|
||||
this.server = server;
|
||||
}
|
||||
|
||||
@@ -250,9 +250,9 @@ public class BuildData {
|
||||
public boolean equals(Object o) {
|
||||
if (o == null)
|
||||
return false;
|
||||
if (!(o instanceof BuildData))
|
||||
if (!(o instanceof SharedBuildData))
|
||||
return super.equals(o);
|
||||
return ((BuildData) o).getId() == id;
|
||||
return ((SharedBuildData) o).getId() == id;
|
||||
}
|
||||
|
||||
}
|
||||
+9
-9
@@ -31,21 +31,21 @@ import me.joshlarson.json.JSONObject;
|
||||
|
||||
import com.projectswg.common.utilities.TimeUtilities;
|
||||
|
||||
public class DeploymentData {
|
||||
public class SharedDeploymentData {
|
||||
|
||||
private final long id;
|
||||
private BuildData build;
|
||||
private SharedBuildData build;
|
||||
private long startTime;
|
||||
private long endTime;
|
||||
|
||||
public DeploymentData(long id, BuildData build) {
|
||||
public SharedDeploymentData(long id, SharedBuildData build) {
|
||||
this.id = id;
|
||||
this.build = build;
|
||||
this.startTime = 0;
|
||||
this.endTime = 0;
|
||||
}
|
||||
|
||||
public DeploymentData(JSONObject json) {
|
||||
public SharedDeploymentData(JSONObject json) {
|
||||
this(json.getLong("id"), null);
|
||||
this.startTime = TimeUtilities.getTimeFromStringUtc(json.getString("start_time"));
|
||||
this.endTime = TimeUtilities.getTimeFromStringUtc(json.getString("end_time"));
|
||||
@@ -65,13 +65,13 @@ public class DeploymentData {
|
||||
return id;
|
||||
}
|
||||
|
||||
public ServerData getServer() {
|
||||
public SharedServerData getServer() {
|
||||
if (build == null)
|
||||
return null;
|
||||
return build.getServer();
|
||||
}
|
||||
|
||||
public BuildData getBuild() {
|
||||
public SharedBuildData getBuild() {
|
||||
return build;
|
||||
}
|
||||
|
||||
@@ -83,7 +83,7 @@ public class DeploymentData {
|
||||
return endTime;
|
||||
}
|
||||
|
||||
public void setBuild(BuildData build) {
|
||||
public void setBuild(SharedBuildData build) {
|
||||
this.build = build;
|
||||
}
|
||||
|
||||
@@ -102,9 +102,9 @@ public class DeploymentData {
|
||||
public boolean equals(Object o) {
|
||||
if (o == null)
|
||||
return false;
|
||||
if (!(o instanceof DeploymentData))
|
||||
if (!(o instanceof SharedDeploymentData))
|
||||
return super.equals(o);
|
||||
return ((DeploymentData) o).getId() == id;
|
||||
return ((SharedDeploymentData) o).getId() == id;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
+15
-15
@@ -31,16 +31,16 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.TreeMap;
|
||||
|
||||
public class ServerData {
|
||||
public class SharedServerData {
|
||||
|
||||
private final String name;
|
||||
private final TreeMap<Long, BuildData> builds;
|
||||
private BuildData lastBuild;
|
||||
private DeploymentData lastDeployment;
|
||||
private final TreeMap<Long, SharedBuildData> builds;
|
||||
private SharedBuildData lastBuild;
|
||||
private SharedDeploymentData lastDeployment;
|
||||
private String directory;
|
||||
private String jvmArgs;
|
||||
|
||||
public ServerData(String name) {
|
||||
public SharedServerData(String name) {
|
||||
this.name = name;
|
||||
this.builds = new TreeMap<>();
|
||||
this.lastBuild = null;
|
||||
@@ -57,32 +57,32 @@ public class ServerData {
|
||||
return jvmArgs;
|
||||
}
|
||||
|
||||
public List<BuildData> getBuildData() {
|
||||
public List<SharedBuildData> getBuildData() {
|
||||
synchronized (builds) {
|
||||
return new ArrayList<>(builds.values());
|
||||
}
|
||||
}
|
||||
|
||||
public BuildData getBuildData(long id) {
|
||||
public SharedBuildData getBuildData(long id) {
|
||||
synchronized (builds) {
|
||||
return builds.get(id);
|
||||
}
|
||||
}
|
||||
|
||||
public BuildData getLastBuild() {
|
||||
public SharedBuildData getLastBuild() {
|
||||
return lastBuild;
|
||||
}
|
||||
|
||||
public DeploymentData getLastDeployment() {
|
||||
public SharedDeploymentData getLastDeployment() {
|
||||
return lastDeployment;
|
||||
}
|
||||
|
||||
public void addBuild(BuildData build) {
|
||||
public void addBuild(SharedBuildData build) {
|
||||
synchronized (builds) {
|
||||
builds.put(build.getId(), build);
|
||||
if (lastBuild == null || lastBuild.getId() < build.getId())
|
||||
lastBuild = build;
|
||||
DeploymentData buildLastDeployment = build.getLastDeployment();
|
||||
SharedDeploymentData buildLastDeployment = build.getLastDeployment();
|
||||
if (lastDeployment == null || (buildLastDeployment != null && buildLastDeployment.getId() > lastDeployment.getId()))
|
||||
lastDeployment = buildLastDeployment;
|
||||
}
|
||||
@@ -117,16 +117,16 @@ public class ServerData {
|
||||
public boolean equals(Object o) {
|
||||
if (o == null)
|
||||
return false;
|
||||
if (!(o instanceof ServerData))
|
||||
if (!(o instanceof SharedServerData))
|
||||
return super.equals(o);
|
||||
return ((ServerData) o).getName().equals(name);
|
||||
return ((SharedServerData) o).getName().equals(name);
|
||||
}
|
||||
|
||||
protected void onDeploymentsChanged() {
|
||||
synchronized (builds) {
|
||||
lastDeployment = null;
|
||||
for (BuildData build : builds.values()) {
|
||||
DeploymentData buildLastDeployment = build.getLastDeployment();
|
||||
for (SharedBuildData build : builds.values()) {
|
||||
SharedDeploymentData buildLastDeployment = build.getLastDeployment();
|
||||
if (lastDeployment == null || (buildLastDeployment != null && buildLastDeployment.getId() > lastDeployment.getId()))
|
||||
lastDeployment = buildLastDeployment;
|
||||
}
|
||||
@@ -42,8 +42,8 @@ import javafx.scene.text.Text;
|
||||
|
||||
import com.projectswg.common.data.TestDetails;
|
||||
import com.projectswg.common.utilities.TimeUtilities;
|
||||
import com.projectswg.lightspeed_frontend.data.BuildData;
|
||||
import com.projectswg.lightspeed_frontend.data.DeploymentData;
|
||||
import com.projectswg.lightspeed_frontend.data.SharedBuildData;
|
||||
import com.projectswg.lightspeed_frontend.data.SharedDeploymentData;
|
||||
import com.projectswg.lightspeed_frontend.gui.table.cell.CellMouseClickCallback;
|
||||
import com.projectswg.lightspeed_frontend.gui.table.cell.TableCellString;
|
||||
import com.projectswg.lightspeed_frontend.gui.table.column.TableColumnString;
|
||||
@@ -53,7 +53,7 @@ public class BuildDataPane extends GridPane implements Initializable {
|
||||
|
||||
private final AtomicBoolean initialized;
|
||||
private final Pane root;
|
||||
private BuildData build;
|
||||
private SharedBuildData build;
|
||||
|
||||
@FXML
|
||||
private Text idText;
|
||||
@@ -72,16 +72,16 @@ public class BuildDataPane extends GridPane implements Initializable {
|
||||
@FXML
|
||||
private Text logText;
|
||||
@FXML
|
||||
private TableView<DeploymentData> deploymentsTable;
|
||||
private TableView<SharedDeploymentData> deploymentsTable;
|
||||
|
||||
public BuildDataPane(Pane root, BuildData build) {
|
||||
public BuildDataPane(Pane root, SharedBuildData build) {
|
||||
this.initialized = new AtomicBoolean(false);
|
||||
this.root = root;
|
||||
setBuildData(build);
|
||||
FrontendFXMLLoader.load(this, "fxml/BuildDataPane.fxml");
|
||||
}
|
||||
|
||||
public void setBuildData(BuildData build) {
|
||||
public void setBuildData(SharedBuildData build) {
|
||||
this.build = build;
|
||||
updateUI();
|
||||
}
|
||||
@@ -103,16 +103,16 @@ public class BuildDataPane extends GridPane implements Initializable {
|
||||
updateUI();
|
||||
}
|
||||
|
||||
private void addServerTableColumn(String name, double width, TableColumnString<DeploymentData> valueFactory, CellMouseClickCallback<DeploymentData> callback) {
|
||||
TableColumn<DeploymentData, String> column = new TableColumn<>(name);
|
||||
private void addServerTableColumn(String name, double width, TableColumnString<SharedDeploymentData> valueFactory, CellMouseClickCallback<SharedDeploymentData> callback) {
|
||||
TableColumn<SharedDeploymentData, String> column = new TableColumn<>(name);
|
||||
column.setCellValueFactory(valueFactory);
|
||||
column.setPrefWidth(width);
|
||||
column.setCellFactory((param) -> new TableCellString<DeploymentData>(callback));
|
||||
column.setCellFactory((param) -> new TableCellString<SharedDeploymentData>(callback));
|
||||
deploymentsTable.getColumns().add(column);
|
||||
}
|
||||
|
||||
private void updateUI() {
|
||||
BuildData build = this.build; // Concurrency thing, move along
|
||||
SharedBuildData build = this.build; // Concurrency thing, move along
|
||||
if (!initialized.get() || build == null)
|
||||
return;
|
||||
idText.setText(Long.toString(build.getId()));
|
||||
@@ -141,20 +141,20 @@ public class BuildDataPane extends GridPane implements Initializable {
|
||||
deploymentsTable.getItems().addAll(build.getDeployments());
|
||||
}
|
||||
|
||||
private static class BuildTableIdColumn extends TableColumnString<DeploymentData> {
|
||||
protected String createText(DeploymentData data) {
|
||||
private static class BuildTableIdColumn extends TableColumnString<SharedDeploymentData> {
|
||||
protected String createText(SharedDeploymentData data) {
|
||||
return Long.toString(data.getId());
|
||||
}
|
||||
}
|
||||
|
||||
private static class BuildTableTimeColumn extends TableColumnString<DeploymentData> {
|
||||
protected String createText(DeploymentData data) {
|
||||
private static class BuildTableTimeColumn extends TableColumnString<SharedDeploymentData> {
|
||||
protected String createText(SharedDeploymentData data) {
|
||||
return TimeUtilities.getDateString(TimeUtilities.convertUtcToLocal(data.getStartTime()));
|
||||
}
|
||||
}
|
||||
|
||||
private static class BuildTableStatusColumn extends TableColumnString<DeploymentData> {
|
||||
protected String createText(DeploymentData data) {
|
||||
private static class BuildTableStatusColumn extends TableColumnString<SharedDeploymentData> {
|
||||
protected String createText(SharedDeploymentData data) {
|
||||
String prefix;
|
||||
double deploymentTime;
|
||||
if (data.getEndTime() == 0) {
|
||||
|
||||
@@ -37,26 +37,26 @@ import javafx.scene.layout.GridPane;
|
||||
import javafx.scene.layout.Pane;
|
||||
import javafx.scene.text.Text;
|
||||
|
||||
import com.projectswg.lightspeed_frontend.data.DeploymentData;
|
||||
import com.projectswg.lightspeed_frontend.data.SharedDeploymentData;
|
||||
import com.projectswg.lightspeed_frontend.javafx.FrontendFXMLLoader;
|
||||
|
||||
public class DeploymentDataPane extends GridPane implements Initializable {
|
||||
|
||||
private final AtomicBoolean initialized;
|
||||
private DeploymentData deployment;
|
||||
private SharedDeploymentData deployment;
|
||||
|
||||
@FXML
|
||||
private Text idText;
|
||||
@FXML
|
||||
private Text serverText;
|
||||
|
||||
public DeploymentDataPane(Pane root, DeploymentData deployment) {
|
||||
public DeploymentDataPane(Pane root, SharedDeploymentData deployment) {
|
||||
this.initialized = new AtomicBoolean(false);
|
||||
setDeploymentData(deployment);
|
||||
FrontendFXMLLoader.load(this, "fxml/DeploymentDataPane.fxml");
|
||||
}
|
||||
|
||||
public void setDeploymentData(DeploymentData deployment) {
|
||||
public void setDeploymentData(SharedDeploymentData deployment) {
|
||||
this.deployment = deployment;
|
||||
updateUI();
|
||||
}
|
||||
@@ -68,7 +68,7 @@ public class DeploymentDataPane extends GridPane implements Initializable {
|
||||
}
|
||||
|
||||
private void updateUI() {
|
||||
DeploymentData deployment = this.deployment; // Concurrency thing, move along
|
||||
SharedDeploymentData deployment = this.deployment; // Concurrency thing, move along
|
||||
if (!initialized.get() || deployment == null)
|
||||
return;
|
||||
idText.setText(Long.toString(deployment.getId()));
|
||||
|
||||
@@ -41,9 +41,9 @@ import com.projectswg.common.utilities.ThreadUtilities;
|
||||
import com.projectswg.common.utilities.TimeUtilities;
|
||||
import com.projectswg.lightspeed_frontend.Frontend;
|
||||
import com.projectswg.lightspeed_frontend.FrontendData.FrontendDataType;
|
||||
import com.projectswg.lightspeed_frontend.data.BuildData;
|
||||
import com.projectswg.lightspeed_frontend.data.DeploymentData;
|
||||
import com.projectswg.lightspeed_frontend.data.ServerData;
|
||||
import com.projectswg.lightspeed_frontend.data.SharedBuildData;
|
||||
import com.projectswg.lightspeed_frontend.data.SharedDeploymentData;
|
||||
import com.projectswg.lightspeed_frontend.data.SharedServerData;
|
||||
import com.projectswg.lightspeed_frontend.gui.table.column.TableColumnString;
|
||||
import com.projectswg.lightspeed_frontend.gui.table.cell.CellMouseClickCallback;
|
||||
import com.projectswg.lightspeed_frontend.gui.table.cell.TableCellString;
|
||||
@@ -87,7 +87,7 @@ public class LightspeedPrimaryView extends StackPane implements Initializable {
|
||||
private Button createServer;
|
||||
|
||||
@FXML
|
||||
private TableView<ServerData> serverTable;
|
||||
private TableView<SharedServerData> serverTable;
|
||||
|
||||
public LightspeedPrimaryView(Frontend frontend) {
|
||||
this.executor = Executors.newSingleThreadExecutor(ThreadUtilities.newThreadFactory("lightspeed-tab"));
|
||||
@@ -128,15 +128,15 @@ public class LightspeedPrimaryView extends StackPane implements Initializable {
|
||||
(data, me) -> onDeploymentClicked(data, me));
|
||||
}
|
||||
|
||||
private void addServerTableColumn(String name, double width, TableColumnString<ServerData> valueFactory, CellMouseClickCallback<ServerData> callback) {
|
||||
TableColumn<ServerData, String> column = new TableColumn<>(name);
|
||||
private void addServerTableColumn(String name, double width, TableColumnString<SharedServerData> valueFactory, CellMouseClickCallback<SharedServerData> callback) {
|
||||
TableColumn<SharedServerData, String> column = new TableColumn<>(name);
|
||||
column.setCellValueFactory(valueFactory);
|
||||
column.setPrefWidth(width);
|
||||
column.setCellFactory((param) -> new TableCellString<ServerData>(callback));
|
||||
column.setCellFactory((param) -> new TableCellString<SharedServerData>(callback));
|
||||
serverTable.getColumns().add(column);
|
||||
}
|
||||
|
||||
private void onServerClicked(ServerData data, MouseEvent event) {
|
||||
private void onServerClicked(SharedServerData data, MouseEvent event) {
|
||||
if (data == null) {
|
||||
onDefaultClick();
|
||||
return;
|
||||
@@ -146,7 +146,7 @@ public class LightspeedPrimaryView extends StackPane implements Initializable {
|
||||
}
|
||||
}
|
||||
|
||||
private void onBuildClicked(ServerData data, MouseEvent event) {
|
||||
private void onBuildClicked(SharedServerData data, MouseEvent event) {
|
||||
if (data == null) {
|
||||
onDefaultClick();
|
||||
return;
|
||||
@@ -163,7 +163,7 @@ public class LightspeedPrimaryView extends StackPane implements Initializable {
|
||||
}
|
||||
}
|
||||
|
||||
private void onDeploymentClicked(ServerData data, MouseEvent event) {
|
||||
private void onDeploymentClicked(SharedServerData data, MouseEvent event) {
|
||||
if (data == null) {
|
||||
onDefaultClick();
|
||||
return;
|
||||
@@ -180,7 +180,7 @@ public class LightspeedPrimaryView extends StackPane implements Initializable {
|
||||
}
|
||||
}
|
||||
|
||||
private void setupServerRightClick(ServerData data, MouseEvent event) {
|
||||
private void setupServerRightClick(SharedServerData data, MouseEvent event) {
|
||||
MenuItem runNew = new MenuItem("Run New Build");
|
||||
runNew.setOnAction((ae) -> frontend.send(PostBuildPacket.create(data.getName())));
|
||||
showSecondaryMenu(event.getScreenX(), event.getScreenY(), runNew);
|
||||
@@ -250,15 +250,15 @@ public class LightspeedPrimaryView extends StackPane implements Initializable {
|
||||
popup.show();
|
||||
}
|
||||
|
||||
private static class ServerTableIdColumn extends TableColumnString<ServerData> {
|
||||
protected String createText(ServerData server) {
|
||||
private static class ServerTableIdColumn extends TableColumnString<SharedServerData> {
|
||||
protected String createText(SharedServerData server) {
|
||||
return server.getName();
|
||||
}
|
||||
}
|
||||
|
||||
private static class ServerTableBuildColumn extends TableColumnString<ServerData> {
|
||||
protected String createText(ServerData server) {
|
||||
BuildData lastBuild = server.getLastBuild();
|
||||
private static class ServerTableBuildColumn extends TableColumnString<SharedServerData> {
|
||||
protected String createText(SharedServerData server) {
|
||||
SharedBuildData lastBuild = server.getLastBuild();
|
||||
if (lastBuild == null)
|
||||
return "Not Built Yet";
|
||||
DateFormat df = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT);
|
||||
@@ -266,9 +266,9 @@ public class LightspeedPrimaryView extends StackPane implements Initializable {
|
||||
}
|
||||
}
|
||||
|
||||
private static class ServerTableDeploymentColumn extends TableColumnString<ServerData> {
|
||||
protected String createText(ServerData server) {
|
||||
DeploymentData lastDeployment = server.getLastDeployment();
|
||||
private static class ServerTableDeploymentColumn extends TableColumnString<SharedServerData> {
|
||||
protected String createText(SharedServerData server) {
|
||||
SharedDeploymentData lastDeployment = server.getLastDeployment();
|
||||
if (lastDeployment == null)
|
||||
return "Not Deployed Yet";
|
||||
if (lastDeployment.getEndTime() == 0) {
|
||||
|
||||
Reference in New Issue
Block a user