use of clojure.lang.Keyword in project storm by apache.
the class ClojureBolt method prepare.
@Override
public void prepare(final Map stormConf, final TopologyContext context, final OutputCollector collector) {
IFn hof = Utils.loadClojureFn(_fnSpec.get(0), _fnSpec.get(1));
try {
IFn preparer = (IFn) hof.applyTo(RT.seq(_params));
final Map<Keyword, Object> collectorMap = new PersistentArrayMap(new Object[] { Keyword.intern(Symbol.create("output-collector")), collector, Keyword.intern(Symbol.create("context")), context });
List<Object> args = new ArrayList<Object>() {
{
add(stormConf);
add(context);
add(collectorMap);
}
};
_bolt = (IBolt) preparer.applyTo(RT.seq(args));
//this is kind of unnecessary for clojure
try {
_bolt.prepare(stormConf, context, collector);
} catch (AbstractMethodError ame) {
}
} catch (Exception e) {
throw new RuntimeException(e);
}
}
use of clojure.lang.Keyword in project storm by apache.
the class ClojureSpout method open.
@Override
public void open(final Map conf, final TopologyContext context, final SpoutOutputCollector collector) {
IFn hof = Utils.loadClojureFn(_fnSpec.get(0), _fnSpec.get(1));
try {
IFn preparer = (IFn) hof.applyTo(RT.seq(_params));
final Map<Keyword, Object> collectorMap = new PersistentArrayMap(new Object[] { Keyword.intern(Symbol.create("output-collector")), collector, Keyword.intern(Symbol.create("context")), context });
List<Object> args = new ArrayList<Object>() {
{
add(conf);
add(context);
add(collectorMap);
}
};
_spout = (ISpout) preparer.applyTo(RT.seq(args));
//this is kind of unnecessary for clojure
try {
_spout.open(conf, context, collector);
} catch (AbstractMethodError ame) {
}
} catch (Exception e) {
throw new RuntimeException(e);
}
}
use of clojure.lang.Keyword in project http-kit by http-kit.
the class AsyncChannel method firstWrite.
// Write first HTTP header and [first chunk data]? to client
private void firstWrite(Object data, boolean close) throws IOException {
ByteBuffer[] buffers;
int status = 200;
Object body = data;
HeaderMap headers;
if (data instanceof Map) {
Map<Keyword, Object> resp = (Map<Keyword, Object>) data;
headers = HeaderMap.camelCase((Map) resp.get(HEADERS));
status = getStatus(resp);
body = resp.get(BODY);
} else {
headers = new HeaderMap();
}
if (headers.isEmpty()) {
// default 200 and text/html
headers.put("Content-Type", "text/html; charset=utf-8");
}
if (request.isKeepAlive && request.version == HttpVersion.HTTP_1_0) {
headers.put("Connection", "Keep-Alive");
}
if (close) {
// normal response, Content-Length. Every http client understand it
buffers = HttpEncode(status, headers, body);
} else {
if (request.version == HttpVersion.HTTP_1_1) {
// first chunk
headers.put("Transfer-Encoding", "chunked");
}
ByteBuffer[] bb = HttpEncode(status, headers, body);
if (body == null) {
buffers = bb;
} else {
buffers = new ByteBuffer[] { // header
bb[0], // chunk size
chunkSize(bb[1].remaining()), // chunk data
bb[1], // terminating CRLF sequence
ByteBuffer.wrap(newLineBytes) };
}
}
if (close) {
onClose(0);
}
server.tryWrite(key, !close, buffers);
}
use of clojure.lang.Keyword in project storm by nathanmarz.
the class ClojureSpout method open.
@Override
public void open(final Map conf, final TopologyContext context, final SpoutOutputCollector collector) {
IFn hof = Utils.loadClojureFn(_fnSpec.get(0), _fnSpec.get(1));
try {
IFn preparer = (IFn) hof.applyTo(RT.seq(_params));
final Map<Keyword, Object> collectorMap = new PersistentArrayMap(new Object[] { Keyword.intern(Symbol.create("output-collector")), collector, Keyword.intern(Symbol.create("context")), context });
List<Object> args = new ArrayList<Object>() {
{
add(conf);
add(context);
add(collectorMap);
}
};
_spout = (ISpout) preparer.applyTo(RT.seq(args));
//this is kind of unnecessary for clojure
try {
_spout.open(conf, context, collector);
} catch (AbstractMethodError ame) {
}
} catch (Exception e) {
throw new RuntimeException(e);
}
}
Aggregations