<commit_before>#!/usr/bin/env ruby

require "socket"
MYHOSTNAME = Socket.gethostname

MANAGER_ADDRESS = "192.168.33.11"
MANAGER_USER = "root"
MANAGER_PASSWORD = ""

require "timeout"
require "mysql2-cs-bind"
require "json"

client = Mysql2::Client.new(
  host: MANAGER_ADDRESS,
  port: 3306,
  username: MANAGER_USER,
  password: <PASSWORD>,
  database: 'isucon_portal',
  reconnect: true,
)
client.query_options.merge!(symbolize_keys: true)

def acquire_queue_entry(client)
  queue_entry_query = <<SQL
SELECT id, team_id, status, ip_address, testset_id, acked_at, submitted_at, json FROM queue WHERE status=? LIMIT 1 FOR UPDATE
SQL
  begin
    client.xquery("BEGIN")
    entry = client.xquery(queue_entry_query, "waiting").first
    unless entry
      client.xquery("ROLLBACK")
      return nil
    end
    acquire_query = "UPDATE queue SET status=?, bench_node=?, acked_at=CURRENT_TIMESTAMP() WHERE id=? "<commit_msg>manageのアドレス更新<commit_after>#!/usr/bin/env ruby

require "socket"
MYHOSTNAME = Socket.gethostname

MANAGER_ADDRESS = "172.16.31.10"
MANAGER_USER = "root"
MANAGER_PASSWORD = ""

require "timeout"
require "mysql2-cs-bind"
require "json"

client = Mysql2::Client.new(
  host: MANAGER_ADDRESS,
  port: 3306,
  username: MANAGER_USER,
  password: <PASSWORD>,
  database: 'isucon_portal',
  reconnect: true,
)
client.query_options.merge!(symbolize_keys: true)

def acquire_queue_entry(client)
  queue_entry_query = <<SQL
SELECT id, team_id, status, ip_address, testset_id, acked_at, submitted_at, json FROM queue WHERE status=? LIMIT 1 FOR UPDATE
SQL
  begin
    client.xquery("BEGIN")
    entry = client.xquery(queue_entry_query, "waiting").first
    unless entry
      client.xquery("ROLLBACK")
      return nil
    end
    acquire_query = "UPDATE queue SET status=?, bench_node=?, acked_at=CURRENT_TIMESTAMP() WHERE id=? "
{'fraction_non_alphanumeric': 0.11540555253130104, 'fraction_numerical': 0.017964071856287425, 'mean_word_length': 4.948220064724919, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, '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': '711020', 'n_tokens_mistral': 691, 'n_tokens_neox': 662, 'n_words': 150}