diff --git a/src/main/java/com/syncleus/aethermud/command/commands/admin/GraphStatusCommand.java b/src/main/java/com/syncleus/aethermud/command/commands/admin/GraphStatusCommand.java
new file mode 100644
index 0000000000000000000000000000000000000000..f64834001f7b2eb41d2da67530cb54fcbff93152
--- /dev/null
+++ b/src/main/java/com/syncleus/aethermud/command/commands/admin/GraphStatusCommand.java
@@ -0,0 +1,64 @@
+/**
+ * Copyright 2017 Syncleus, Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.syncleus.aethermud.command.commands.admin;
+
+import com.google.common.collect.Sets;
+import com.syncleus.aethermud.command.commands.Command;
+import com.syncleus.aethermud.core.GameManager;
+import com.syncleus.aethermud.player.PlayerRole;
+import com.syncleus.aethermud.storage.AetherMudStorage;
+import com.syncleus.aethermud.storage.GraphInfo;
+import com.syncleus.aethermud.storage.graphdb.GraphStorageFactory;
+import org.jboss.netty.channel.ChannelHandlerContext;
+import org.jboss.netty.channel.MessageEvent;
+
+import java.util.Arrays;
+import java.util.List;
+import java.util.Set;
+
+public class GraphStatusCommand extends Command {
+ final static List<String> validTriggers = Arrays.asList("graphstatus");
+ final static String description = "Display some statistics on the GraphDB for debugging.";
+ final static String correctUsage = "graphstatus";
+ final static Set<PlayerRole> roles = Sets.newHashSet(PlayerRole.ADMIN);
+
+ public GraphStatusCommand(GameManager gameManager) {
+ super(gameManager, validTriggers, description, correctUsage, roles);
+ }
+
+ @Override
+ public void messageReceived(ChannelHandlerContext ctx, MessageEvent e) throws Exception {
+ execCommand(ctx, e, () -> {
+
+ try (GraphStorageFactory.AetherMudTx tx = this.gameManager.getGraphStorageFactory().beginTransaction()) {
+ AetherMudStorage storage = tx.getStorage();
+ GraphInfo info = storage.getGraphInfo();
+
+ write("Number of nodes: " + info.getNumberOfNodes() + "\r\n");
+ write("Number of items: " + info.getNumberOfItems() + "\r\n");
+ write("Number of item instances: " + info.getNumberOfItemInstances() + "\r\n");
+ write("Number of item internal names:\r\n");
+ for(String internalName : info.getItemInternalNames())
+ write(internalName + "\r\n");
+ }
+
+ });
+ }
+
+}
+
+
+
diff --git a/src/main/java/com/syncleus/aethermud/configuration/ConfigureCommands.java b/src/main/java/com/syncleus/aethermud/configuration/ConfigureCommands.java
index df8139fdbc195a4eb1f99408867c1867631e39dd..587510ab28dcc7347cbd60f803a25d4e62cdf995 100644
--- a/src/main/java/com/syncleus/aethermud/configuration/ConfigureCommands.java
+++ b/src/main/java/com/syncleus/aethermud/configuration/ConfigureCommands.java
@@ -122,5 +122,6 @@ public class ConfigureCommands {
commandRegistry.addCommand(new LoadMerchantCommand(gameManager));
commandRegistry.addCommand(new RestartCommand(gameManager));
commandRegistry.addCommand(new GiveHealthCommand(gameManager));
+ commandRegistry.addCommand(new GraphStatusCommand(gameManager));
}
}
diff --git a/src/main/java/com/syncleus/aethermud/storage/AetherMudStorage.java b/src/main/java/com/syncleus/aethermud/storage/AetherMudStorage.java
index ce33fa66370ca760233d23a7555e7abe246a2310..f19d20a08a58b3bc0c559d88ceb3af6f811eee46 100644
--- a/src/main/java/com/syncleus/aethermud/storage/AetherMudStorage.java
+++ b/src/main/java/com/syncleus/aethermud/storage/AetherMudStorage.java
@@ -56,4 +56,7 @@ public interface AetherMudStorage {
List<? extends NpcData> getNpcDatas();
NpcData newNpcData();
+
+ GraphInfo getGraphInfo();
+
}
diff --git a/src/main/java/com/syncleus/aethermud/storage/GraphInfo.java b/src/main/java/com/syncleus/aethermud/storage/GraphInfo.java
new file mode 100644
index 0000000000000000000000000000000000000000..5d42629c78be1aa318fdc4372cfdcbff25c5ee8e
--- /dev/null
+++ b/src/main/java/com/syncleus/aethermud/storage/GraphInfo.java
@@ -0,0 +1,48 @@
+/**
+ * Copyright 2017 Syncleus, Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.syncleus.aethermud.storage;
+
+import java.util.List;
+
+public class GraphInfo {
+ private final int numberOfItems;
+ private final int numberOfItemInstances;
+ private final List<String> itemInternalNames;
+ private final int numberOfNodes;
+
+ public GraphInfo(int numberOfItems, int numberOfItemInstances, List<String> itemInternalNames, int numberOfNodes) {
+ this.numberOfItems = numberOfItems;
+ this.numberOfItemInstances = numberOfItemInstances;
+ this.itemInternalNames = itemInternalNames;
+ this.numberOfNodes = numberOfNodes;
+ }
+
+ public int getNumberOfItems() {
+ return numberOfItems;
+ }
+
+ public int getNumberOfItemInstances() {
+ return numberOfItemInstances;
+ }
+
+ public List<String> getItemInternalNames() {
+ return itemInternalNames;
+ }
+
+ public int getNumberOfNodes() {
+ return numberOfNodes;
+ }
+}
diff --git a/src/main/java/com/syncleus/aethermud/storage/graphdb/GraphDbAetherMudStorage.java b/src/main/java/com/syncleus/aethermud/storage/graphdb/GraphDbAetherMudStorage.java
index 1c32b0228ad975cae5a13609132c4a2f7be7ce8a..2ca865aa6fcd541b519d5786baa8d5e592e53c9c 100644
--- a/src/main/java/com/syncleus/aethermud/storage/graphdb/GraphDbAetherMudStorage.java
+++ b/src/main/java/com/syncleus/aethermud/storage/graphdb/GraphDbAetherMudStorage.java
@@ -23,10 +23,12 @@ import com.syncleus.aethermud.items.ItemInstance;
import com.syncleus.aethermud.npc.NpcBuilder;
import com.syncleus.aethermud.npc.NpcSpawn;
import com.syncleus.aethermud.storage.AetherMudStorage;
+import com.syncleus.aethermud.storage.GraphInfo;
import com.syncleus.aethermud.storage.graphdb.model.ItemData;
import com.syncleus.aethermud.storage.graphdb.model.ItemInstanceData;
import com.syncleus.aethermud.storage.graphdb.model.NpcData;
import com.syncleus.aethermud.storage.graphdb.model.PlayerData;
+import com.syncleus.ferma.VertexFrame;
import com.syncleus.ferma.WrappedFramedGraph;
import org.apache.log4j.Logger;
import org.apache.tinkerpop.gremlin.structure.Graph;
@@ -88,7 +90,7 @@ public class GraphDbAetherMudStorage implements AetherMudStorage {
itemInstanceData = existing.get();
else
itemInstanceData = framedGraph.addFramedVertex(ItemInstanceData.class);
- ItemInstanceData.copyItem(itemInstanceData, itemInstance, this.getItem(itemInstance.getItem().getInternalItemName()).get());
+ ItemInstanceData.copyItem(itemInstanceData, itemInstance, this.saveItem(itemInstance.getItem()));
return itemInstanceData;
}
}
@@ -127,6 +129,19 @@ public class GraphDbAetherMudStorage implements AetherMudStorage {
}
}
+ @Override
+ public GraphInfo getGraphInfo() {
+ final List<? extends ItemData> allItems = this.getAllItems();
+ final int numberOfItems = allItems.size();
+ final List<String> internalNames = new ArrayList<>();
+ for(ItemData itemData : allItems) {
+ internalNames.add(itemData.getInternalItemName());
+ }
+ final int numberOfItemInstances = framedGraph.traverse((g) -> framedGraph.getTypeResolver().hasType(g.V(), ItemInstanceData.class)).toList(ItemInstanceData.class).size();
+ final int numberOfNodes = framedGraph.traverse((g) -> g.V()).toList(VertexFrame.class).size();
+ return new GraphInfo(numberOfItems, numberOfItemInstances, internalNames, numberOfNodes);
+ }
+
public List<? extends NpcSpawn> getAllNpcs(GameManager gameManager) {
List<? extends NpcData> npcDatas = this.getNpcDatas();
return npcDatas.stream()