XXX: From o.a.zk.t.ClientBase
555921
private static boolean waitForServerUp(String hostname, int port, long timeout) {
    long start = System.currentTimeMillis();
    while (true) {
      try {
        Socket sock = new Socket(hostname, port);
        BufferedReader reader = null;
        try {
          OutputStream outstream = sock.getOutputStream();
          outstream.write("stat".getBytes());
          outstream.flush();

          Reader isr = new InputStreamReader(sock.getInputStream());
          reader = new BufferedReader(isr);
          String line = reader.readLine();
          if (line != null && line.startsWith("Zookeeper version:")) {
            return true;
          }
        } finally {
          sock.close();
          if (reader != null) {
            reader.close();
          }
        }
      } catch (IOException e) {
        // ignore as this is expected
        logger.info("server " + hostname + ":" + port + " not up " + e);
      }

      if (System.currentTimeMillis() > start + timeout) {
        break;
      }
      try {
        Thread.sleep(250);
      } catch (InterruptedException e) {
        // ignore
      }
    }
    return false;
  }
382750
@RequestMapping(value = "/zkdeploy", method = RequestMethod.GET)
    @ResponseBody
    public JsonObjectBase getZkDeployInfo(@Valid ZkDeployForm zkDeployForm) {

        LOG.info(zkDeployForm.toString());

        ConfigFullModel configFullModel = zkDeployValidator.verify(zkDeployForm);

        String data = zkDeployMgr.getDeployInfo(configFullModel.getApp().getName(), configFullModel.getEnv().getName(),
                zkDeployForm.getVersion());

        return buildSuccess("hostInfo", data);
    }
537471
def fetch_nodes
      data = @zk.get(redis_nodes_path, :watch => true).first
      nodes = symbolize_keys(decode(data))
      logger.debug("Fetched nodes: #{nodes.inspect}")

      nodes
    rescue Zookeeper::Exceptions::InheritedConnectionError, ZK::Exceptions::InterruptedSession => ex
      logger.debug { "Caught #{ex.class} '#{ex.message}' - reopening ZK client" }
      @zk.reopen
      retry
    rescue *ZK_ERRORS => ex
      logger.warn { "Caught #{ex.class} '#{ex.message}' - retrying" }
      sleep(RETRY_WAIT_TIME)
      retry
    end
560942
def client
      @client ||= TapClutch::Client.new(
        api_key: config['api_key'],
        api_secret: config['api_secret'],
        api_base: config['api_base'],
        brand: config['brand'],
        location: config['location'],
        terminal: config['terminal'],
        username: config['username'],
        password: config['password'],
        verbose: verbose,
        state: Concurrent::Hash.new.merge!(state),
        stream: stream
      )
    end
778164
private static ModelNode getServerfactory(CommandContext ctx, String point, String name) throws OperationFormatException, IOException {
        DefaultOperationRequestBuilder builder = new DefaultOperationRequestBuilder();
        builder.setOperationName(Util.READ_RESOURCE);
        for (String p : point.split("/")) {
            if (p.isEmpty()) {
                continue;
            }
            String[] ps = p.split("=");
            if (ps[1].equals("*")) {
                ps[1] = name;
            }
            builder.addNode(ps[0], ps[1]);
        }
        builder.getModelNode().get(Util.INCLUDE_RUNTIME).set(true);
        ModelNode response = ctx.getModelControllerClient().execute(builder.buildRequest());
        if (Util.isSuccess(response)) {
            return response.get(Util.RESULT);
        }
        return null;
    }
467431
function oauth(id, username, email, req, done) {
	if (req.params["0"] === "/link") {
		return done(null, {
			__linkUser: true,
			email: email,
			username: username,
			id: id
		});
	}
	fileUtil.getMetastoreSafe(req).then(function(store) {
		store.getUserByOAuth(id, function(err, user) {
			if (err) {
				return done(err);
			}
			if (!user) {
				return done(null, {
					__newUser: true,
					email: email,
					username: username,
					id: id
				});
			}
			done(null, user);
		}, function noMetastore(err) {
			done(err);
		});
	});
}
1110518
public static void main(String[] args) throws IOException {

      // Create a client factory
      FhirContext ctx = FhirContext.forDstu2();

      // Create the client
      String serverBase = "http://fhir.healthintersections.com.au/open";
      ClientInterface client = ctx.newRestfulClient(ClientInterface.class, serverBase);

      // Invoke the client to search for patient
      List<Patient> patients = client.findPatientsForMrn(new IdentifierDt("urn:oid:1.2.36.146.595.217.0.1", "12345"));

      System.out.println("Found " + patients.size() + " patients");

      // Print a value from the loaded resource
      Patient patient = patients.get(0);
      System.out.println("Patient Last Name: " + patient.getName().get(0).getFamily().get(0).getValue());

      // Load a referenced resource
      ResourceReferenceDt managingRef = patient.getManagingOrganization();
      Organization org = (Organization) managingRef.loadResource(client);

      // Print organization name
      System.out.println(org.getName());

   }
161397
@Override
    public OObjectDatabaseTx acquireDb() {
        OObjectDatabaseTx db = server.acquire();
        ODatabaseRecordThreadLocal.INSTANCE.set(db.getUnderlying());
        return db;
    }
1198241
def client_data(typ, challenge)
      JSON.dump(
        challenge: challenge,
        origin: app_id,
        typ: typ
      )
    end
1118088
function Client(config = {}) {
  this.config = config;
  this.logger = new Logger(config);

  //Client is a required field, so throw error if it's not supplied.
  //If 'this.dialect' is set, then this is a 'super()' call, in which case
  //'client' does not have to be set as it's already assigned on the client prototype.

  if (this.dialect && !this.config.client) {
    this.logger.warn(
      `Using 'this.dialect' to identify the client is deprecated and support for it will be removed in the future. Please use configuration option 'client' instead.`
    );
  }
  const dbClient = this.config.client || this.dialect;
  if (!dbClient) {
    throw new Error(`knex: Required configuration option 'client' is missing.`);
  }

  if (config.version) {
    this.version = config.version;
  }

  this.connectionSettings = cloneDeep(config.connection || {});
  if (this.driverName && config.connection) {
    this.initializeDriver();
    if (!config.pool || (config.pool && config.pool.max !== 0)) {
      this.initializePool(config);
    }
  }
  this.valueForUndefined = this.raw('DEFAULT');
  if (config.useNullAsDefault) {
    this.valueForUndefined = null;
  }
}
625233
def get_db_session(engine):
    ""

    db = scoped_session(sessionmaker(extension=ZopeTransactionExtension()))
    db.configure(bind=engine)
    db.autoflush = True

    return db
604238
def _client_data(self, client):
        
        data = {}
        if client:
            data['obj'] = client
            data['id'] = client.id
            data['url'] = client.absolute_url()
            data['name'] = to_utf8(client.getName())
        return data
101106
function getInstanceDetail(client, db, done) {
  const tasks = {
    client: attach.bind(null, client),
    db: attach.bind(null, db),
    userInfo: ['client', 'db', getUserInfo],

    host: ['client', 'db', getHostInfo],
    build: ['client', 'db', getBuildInfo],
    cmdLineOpts: ['client', 'db', getCmdLineOpts],
    genuineMongoDB: ['build', 'cmdLineOpts', getGenuineMongoDB],

    listDatabases: ['client', 'db', 'userInfo', listDatabases],
    allowedDatabases: ['userInfo', getAllowedDatabases],
    databases: [
      'client',
      'db',
      'listDatabases',
      'allowedDatabases',
      getDatabases
    ],

    listCollections: ['client', 'db', 'databases', listCollections],
    allowedCollections: ['userInfo', getAllowedCollections],
    collections: [
      'client',
      'db',
      'listCollections',
      'allowedCollections',
      getCollections
    ],

    hierarchy: ['databases', 'collections', getHierarchy],

    stats: ['databases', getStats]
  };

  async.auto(tasks, function(err, results) {
    if (err) {
      // report error
      return done(err);
    }
    // cleanup
    results = omit(results, [
      'db',
      'listDatabases',
      'allowedDatabases',
      'userInfo',
      'listCollections',
      'allowedCollections',
      'cmdLineOpts'
    ]);
    return done(null, results);
  });
}
1120814
def simxGetObjects(clientID, objectType, operationMode):
    '''
    
    '''

    objectCount = ct.c_int()
    objectHandles = ct.POINTER(ct.c_int)()

    ret = c_GetObjects(clientID, objectType, ct.byref(objectCount), ct.byref(objectHandles), operationMode)
    handles = []
    if ret == 0:
        for i in range(objectCount.value):
            handles.append(objectHandles[i])

    return ret, handles
73456
function makeTxClient(trx, client, connection) {
  const trxClient = Object.create(client.constructor.prototype);
  trxClient.version = client.version;
  trxClient.config = client.config;
  trxClient.driver = client.driver;
  trxClient.connectionSettings = client.connectionSettings;
  trxClient.transacting = true;
  trxClient.valueForUndefined = client.valueForUndefined;
  trxClient.logger = client.logger;

  trxClient.on('query', function(arg) {
    trx.emit('query', arg);
    client.emit('query', arg);
  });

  trxClient.on('query-error', function(err, obj) {
    trx.emit('query-error', err, obj);
    client.emit('query-error', err, obj);
  });

  trxClient.on('query-response', function(response, obj, builder) {
    trx.emit('query-response', response, obj, builder);
    client.emit('query-response', response, obj, builder);
  });

  const _query = trxClient.query;
  trxClient.query = function(conn, obj) {
    const completed = trx.isCompleted();
    return Promise.try(function() {
      if (conn !== connection)
        throw new Error('Invalid connection for transaction query.');
      if (completed) completedError(trx, obj);
      return _query.call(trxClient, conn, obj);
    });
  };
  const _stream = trxClient.stream;
  trxClient.stream = function(conn, obj, stream, options) {
    const completed = trx.isCompleted();
    return Promise.try(function() {
      if (conn !== connection)
        throw new Error('Invalid connection for transaction query.');
      if (completed) completedError(trx, obj);
      return _stream.call(trxClient, conn, obj, stream, options);
    });
  };
  trxClient.acquireConnection = function() {
    return Promise.resolve(connection);
  };
  trxClient.releaseConnection = function() {
    return Promise.resolve();
  };

  return trxClient;
}
298509
def get_x():
    '''
    
    '''
    cmd = 'setxkbmap -query | grep layout'
    out = __salt__['cmd.run'](cmd, python_shell=True).split(':')
    return out[1].strip()
1026430
function Client(opts) {

    this.opts = new clientOptions(opts)
    this.streamData = {}
    this.currentIndex = 0
    this.cachedItems = new lru({maxSize: this.opts.maxCacheSize})
}