memory value problem
import org.terasology.entitySystem.systems.BaseComponentSystem;
import org.terasology.entitySystem.systems.RegisterSystem;
+import java.net.MalformedURLException;
+import java.net.URL;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
private final String appId = "terasology";
- private final String url = "http://localhost:80";
+ private final URL url = urlInit("http","localhost",80);
private final DevicePlatform platform = DevicePlatform.Desktop;
private static final Logger logger = LoggerFactory.getLogger(TelemetrySystem.class);
+ private URL urlInit(String protocal, String host, int port) {
+ URL url = null;
+ try {
+ url = new URL(protocal, host, port, "");
+ } catch (MalformedURLException e) {
+ logger.error("telemetry url mal formed");
+ e.printStackTrace();
+ }
+ return url;
+ }
@Override
public void initialise() {
@@ -69,7 +81,7 @@ public void initialise() {
// Build the adapter
HttpClientAdapter adapter = ApacheHttpClientAdapter.builder()
- .url(url)
+ .url(url.toString())
.httpClient(client)
.build();
@@ -144,7 +156,7 @@ private void systemContextTrack() {
systemContext.put("processorNumbers",processorNumbers);
long memoryMaxByte = Runtime.getRuntime().maxMemory();
- int memoryMaxMb = (int)memoryMaxByte/(1024*1024);
+ int memoryMaxMb = (int) (memoryMaxByte/(1024*1024));
systemContext.put("memoryMax",memoryMaxMb);
SelfDescribingJson systemConextData = new SelfDescribingJson(SCHEMA_OS, systemContext);
