<commit_before>var net = require('net');

var util = require('./lib/util');
var knode = require('./lib/knode');

var self = process.argv[2].split(':');
var port = parseInt(self[1] || 10000);
var node = new knode.KNode({ address: self[0], port: port });

if (process.argv.length >= 4) {
    var arg = process.argv[3].split(':');
    if (arg[0])
        node.connect(arg[0], parseInt(arg[1]));
    setInterval(function() {
        /*node.get('foo', function(err, value) {
            if (err) {
                console.log("Not found");
                node.set('foo', 'bar', function(err) {
                    node.get('foo', function(err, value) {
                        if (err)
                            console.log("Still not inserted");
                        else
                            console.log("======> Inserted", value);
                    });
                });
            }
            else {
                console.log("=======> Already exists", value);
            }
        });*/
        if (port == 10000)
            node.set('foo', 'bar');
        console.log("This node storage", node._storage);
    }, 4000);

    // 'interactive' console
    net.createServer(function(socket) {
        socket.setEncoding('utf8');
        socket.on('data', function(data) {
            var parts = data.trim().split(' ');
            console.log(parts);
            switch (parts[0]) {
                case 'set':
                    if (parts.length < 3) {
                        socket.write("Not enough parameters\n");
                        break;
                    }
                    node.set(parts[1], parts[2], function(err) {
                        if (err)
                            socket.write("Error setting " + parts[1] + ": " + JSON.stringify(err) + "\n");
                        else
                            socket.write("Set " + parts[1] + " to " + parts[2] + "\n");
                    });
                    break;

                case 'get':
                    if (parts.length < 2) {
                        socket.write("Not enough parameters\n");<commit_msg>exit run.js if connect fails<commit_after>var net = require('net');

var util = require('./lib/util');
var knode = require('./lib/knode');

var self = process.argv[2].split(':');
var port = parseInt(self[1] || 10000);
var node = new knode.KNode({ address: self[0], port: port });

if (process.argv.length >= 4) {
    var arg = process.argv[3].split(':');
    if (arg[0])
        node.connect(arg[0], parseInt(arg[1]), function(err) {
            console.log(err);
            process.exit(1);
        });
}

    // 'interactive' console
    net.createServer(function(socket) {
        socket.setEncoding('utf8');
        socket.on('data', function(data) {
            var parts = data.trim().split(' ');
            console.log(parts);
            switch (parts[0]) {
                case 'set':
                    if (parts.length < 3) {
                        socket.write("Not enough parameters\n");
                        break;
                    }
                    node.set(parts[1], parts[2], function(err) {
                        if (err)
                            socket.write("Error setting " + parts[1] + ": " + JSON.stringify(err) + "\n");
                        else
                            socket.write("Set " + parts[1] + " to " + parts[2] + "\n");
                    });
                    break;

                case 'get':
                    if (parts.length < 2) {
                        socket.write("Not enough parameters\n");
{'fraction_non_alphanumeric': 0.16150627615062763, 'fraction_numerical': 0.01506276150627615, 'mean_word_length': 1.3331164606376058, 'pattern_counts': {'":': 2, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6727287', 'n_tokens_mistral': 1012, 'n_tokens_neox': 948, 'n_words': 204}