Skip to content

Instantly share code, notes, and snippets.

View kzk's full-sized avatar
🍶

Kazuki Ohta kzk

🍶
View GitHub Profile
/*
sedue.arc0
sedue.system.indexes
sedue.arc1
{ _id: ObjId(4bffe5311422d029a79f7208), filename: "myfile", length: 2165584, chunkSize: 262144, uploadDate: new Date(1275061553566), md5: "801879daffc1edcb96bd3e11a038ffd7" }
file found
nChunks: 9
Success write
*/
//
// 2010/11/06 Kazuki Ohta <[email protected]>
// Single-Threaded HTTPServer using evhttp
//
#include <event.h>
#include <evhttp.h>
#include <unistd.h>
namespace servers {
@kzk
kzk / evhttp-multh-thread-httpd.cpp
Created November 6, 2010 13:53
Multi-Threaded HTTPServer using evhttp
#include <event.h>
#include <evhttp.h>
#include <pthread.h>
#include <errno.h>
#include <string.h>
#include <fcntl.h>
#include <sys/socket.h>
#include <sys/types.h>
#include <netinet/in.h>
#include <iostream>
import org.msgpack.MessagePack;
import org.msgpack.annotation.MessagePackMessage;
public class Main {
@MessagePackMessage
public static class MyClass {
public String str;
}
public static void main(String[] args) {
import java.io.DataInput;
import java.io.DataOutput;
import java.io.IOException;
import org.apache.hadoop.io.BytesWritable;
import org.apache.hadoop.io.WritableComparable;
import org.msgpack.MessagePack;
public class MessagePackWritable<C> implements WritableComparable<MessagePackWritable<C>> {
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
public class Main {
public static class MyClass {
public String s;
public int v;
class ExistingClass implements MessagePackTemplateProvider {
// no serialization is needed;
Logger LOG;
string internal_data;
// data
int a;
int b;
string c;
package net.kzk9;
import java.io.IOException;
import java.util.StringTokenizer;
import org.apache.hadoop.util.GenericOptionsParser;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.LongWritable;
public class MyWritable implements Writable {
// Some data
private int counter;
private long timestamp;
public void write(DataOutput out) throws IOException {
out.writeInt(counter);
out.writeLong(timestamp);
}
public class MyWritableComparable implements WritableComparable<MyWritableComparable> {
// Some data
private int counter;
private long timestamp;
public void write(DataOutput out) throws IOException {
out.writeInt(counter);
out.writeLong(timestamp);
}