Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
var thrift = require('thrift'),
ttransport = require('thrift/transport');
var UserStorage = require('./gen-nodejs/UserStorage'),
ttypes = require('./gen-nodejs/user_types');
var f_conn = thrift.createConnection('localhost', 9090), // default: framed
f_client = thrift.createClient(UserStorage, f_conn);
var b_conn = thrift.createConnection('localhost', 9091, {transport: ttransport.TBufferedTransport}),
b_client = thrift.createClient(UserStorage, b_conn);
var user1 = new ttypes.UserProfile({uid: 1,
name: "Mark Slee",
blurb: "I'll find something to put here."});
var user2 = new ttypes.UserProfile({uid: 2,
name: "Satoshi Tagomori",
blurb: "ok, let's test with buffered transport."});
f_conn.on('error', function(err) {
console.error("framed:", err);
});
f_client.store(user1, function(err, response) {
if (err) { console.error(err); return; }
console.log("stored:", user1.uid, " as ", user1.name);
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
var thrift = require('thrift'),
ttransport = require('thrift/transport');
var UserStorage = require('./gen-nodejs/UserStorage'),
ttypes = require('./gen-nodejs/user_types');
var f_conn = thrift.createConnection('localhost', 9090), // default: framed
f_client = thrift.createClient(UserStorage, f_conn);
var b_conn = thrift.createConnection('localhost', 9091, {transport: ttransport.TBufferedTransport}),
b_client = thrift.createClient(UserStorage, b_conn);
var user1 = new ttypes.UserProfile({uid: 1,
name: "Mark Slee",
blurb: "I'll find something to put here."});
var user2 = new ttypes.UserProfile({uid: 2,
name: "Satoshi Tagomori",
blurb: "ok, let's test with buffered transport."});
f_conn.on('error', function(err) {
console.error("framed:", err);
});
f_client.store(user1, function(err, response) {
if (err) { console.error(err); return; }
console.log("stored:", user1.uid, " as ", user1.name);
var thrift = require('thrift'),
ttransport = require('thrift/transport'),
ThriftHive = require('./gen-nodejs/ThriftHive');
var connection = thrift.createConnection("localhost", 10000, {transport: ttransport.TBufferedTransport, timeout: 600*1000}),
client = thrift.createClient(ThriftHive, connection);
connection.on('error', function(err) {
console.error(err);
});
connection.addListener("connect", function() {
client.execute('select count(*) from p', function(err){
console.error("pos");
if (err) { console.error("error on execute(): " + err); process.exit(1); }
client.fetchAll(function(err, data){
if (err){ console.error("error on fetchAll(): " + err); process.exit(1); }
console.error(data);
connection.end();
process.exit(0);
var thrift = require('thrift'),
ttransport = require('thrift/transport'),
ThriftHive = require('gen-nodejs/ThriftHive');
var connection = thrift.createConnection("localhost", 10000, {transport: ttransport.TBufferedTransport, timeout: 600*1000}),
client = thrift.createClient(ThriftHive, connection);
connection.on('error', function(err) {
console.error(err);
});
connection.addListener("connect", function() {
client.getClusterStatus(function(err, data){
console.log("getClusterStatus:", data);
client.execute('select x, count(*) as cnt from p group by x sort by cnt limit 10', function(err){
if (err) { console.error("error on execute(): " + err); process.exit(1); }
client.getQueryPlan(function(err, data){
console.log("getQueryPlan:", data);
console.log("queryplan queryAttributes:", data.queries[0].queryAttributes);
console.log("queryplan stageGraph:", data.queries[0].stageGraph);
success();
};
var retrieve = function(uid, success) {
console.log("retrieved:", uid);
success(users[uid]);
};
var server_framed = thrift.createServer(UserStorage, {
store: store,
retrieve: retrieve
});
server_framed.listen(9090);
var server_buffered = thrift.createServer(UserStorage, {
store: store,
retrieve: retrieve
}, {transport: ttransport.TBufferedTransport});
server_buffered.listen(9091);
result(null);
};
var retrieve = function(uid, result) {
console.log("retrieved:", uid);
result(null, users[uid]);
};
var server_framed = thrift.createServer(UserStorage, {
store: store,
retrieve: retrieve
});
server_framed.listen(9090);
var server_buffered = thrift.createServer(UserStorage, {
store: store,
retrieve: retrieve
}, {transport: ttransport.TBufferedTransport});
server_buffered.listen(9091);