Skip to content

Commit

Permalink
[POC-4] console, other fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
apfadler committed Jun 30, 2016
1 parent 5b228fe commit 13c3682
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 15 deletions.
8 changes: 8 additions & 0 deletions common/src/main/scala/org/quil/JSON/package.scala
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,14 @@ package org.quil.JSON {
implicit def documentToMap(d: Document): Map[String, Any] = d.fields
}

object Document {
def apply(fields:Map[String,Any]):Document = {
val doc = new Document("{}")
doc.apply(fields)
doc
}
}

class Document(private var jsonStr:String) {

implicit val formats = org.json4s.DefaultFormats
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class RunQLObjectsApplication(val taskName:String, val taskDescription:String) e
case e: Exception => {
}
}
ResultsCache.add(_taskName, _taskTag, 0, key, strVal, doubleVal, intVal)
ResultsCache.add(_taskName, _taskTag, 0, "",key, strVal, doubleVal, intVal)
}
}
}
21 changes: 13 additions & 8 deletions scala-console/src/main/java/org/quil/console/ScalaConsole.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
import org.apache.ignite.configuration.IgniteConfiguration;
import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder;
import org.quil.server.QuilServer;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand Down Expand Up @@ -46,8 +45,14 @@ public static void main( String[] args )

CommandLineParser parser = new BasicParser();

String scriptInit = "import org.quil.server._;import org.quil.interpreter._; "+
"import org.quil.server.Tasks._; import org.quil.server.Tasks._; import org.quil.interpreter.QuantLibTemplates; import scala.collection.JavaConversions._;";
String scriptInit = "import org.quil.server._;import org.quil.interpreter._; import org.quil.JSON._; import org.apache.ignite.scalar.scalar._;"+
"import org.quil.server.Tasks._; import org.quil.server.Tasks._; import org.quil.interpreter.QuantLibTemplates._; import scala.collection.JavaConversions._;"
+"def query(sql:String) = {\n" +
" import org.apache.ignite.cache.query.SqlQuery\n" +
" import org.apache.ignite.cache.query.SqlFieldsQuery\n" +
" val cache = ignite$.cache(\"Tasks\")\n" +
" cache.query(new SqlFieldsQuery(sql)) map { x => x }\n" +
"}";

String loadScript = "";
CommandLine cmd = null;
Expand Down Expand Up @@ -97,14 +102,14 @@ public static void main( String[] args )
} catch (Exception e) {
}

logger.info("Client mode = " + clientmode);
//logger.info("Client mode = " + clientmode);

cfg.setClientMode(clientmode);
cfg.setPeerClassLoadingEnabled(true);
cfg.setIncludeEventTypes(EVTS_TASK_EXECUTION);
//cfg.setClientMode(clientmode);
//cfg.setPeerClassLoadingEnabled(true);
//cfg.setIncludeEventTypes(EVTS_TASK_EXECUTION);

// Connect to ignite and run console
try (Ignite ignite = Ignition.start(cfg)) {
try (Ignite ignite = Ignition.start("config/quil-client.xml")) {

logger.info("Connected to Ignite Cluster.");

Expand Down
7 changes: 1 addition & 6 deletions server/src/main/java/org/quil/server/DocumentCacheAPI.java
Original file line number Diff line number Diff line change
Expand Up @@ -186,13 +186,8 @@ public String addJSONArray(@PathParam("cacheid") String cacheid, String data) {


DocumentCache cache = DocumentCache.getOrCreate(cacheid);

//JSONParser parser = new JSONParser();
//JSONArray jsonArray = (JSONArray) parser.parse(data);

for (int i=0; i < starts.size(); i++ ) {

System.out.println(data.substring(starts.get(i),ends.get(i)));
for (int i=0; i < starts.size(); i++ ) {
cache.put(cacheid+"_" + UUID.randomUUID(),
(Document)((new org.quil.JSON.Parser()).parse(data.substring(starts.get(i),ends.get(i)))));
}
Expand Down

0 comments on commit 13c3682

Please sign in to comment.