<commit_before>AGENT_ROOT = File.dirname(__FILE__)

require 'rubygems'
require 'active_support'
require 'systemu'
require 'sexpistol'
require "#{AGENT_ROOT}/../cm/logger.rb"
require "#{AGENT_ROOT}/../cm/agent.rb"
require "#{AGENT_ROOT}/../cm/kb.rb"
require "#{AGENT_ROOT}/../cm/cirrocumulus.rb"

# load corresponding backend
require "#{AGENT_ROOT}/storage_config.rb"
require "#{AGENT_ROOT}/#{Cirrocumulus::platform}/#{STORAGE_BACKEND}/storage_node.rb"

require "#{AGENT_ROOT}/storage_db.rb"

class StorageAgent < Agent
  def initialize(cm)
    super(cm)
    @default_ontology = 'cirrocumulus-storage'
  end
  
  def restore_state()
    StorageNode.list_disks().each do |disk_number|
      export_is_up = StorageNode.is_exported?(disk_number)
      export_should_be_up = AgentState.export_should_be_up?(disk_number)
      
      if export_should_be_up && !export_is_up
        Log4r::Logger['agent'].info "bringing up export #{disk_number}"
      elsif !export_should_be_up && export_is_up
        Log4r::Logger['agent'].info "shutting down export #{disk_number}"
      end
    end
    
    Log4r::Logger['agent'].info "restored agent state"
  end

  def handle(message, kb)
    s = Sexpistol.new
    case message.act
      when 'query-ref'
        msg = query(message.content)
        msg.receiver = message.sender
        msg.ontology = @default_ontology
        msg.in_reply_to = message.reply_with
        @cm.send(msg)

      when 'query-if'
        msg = query_if(message.content)
        msg.receiver = message.sender
        msg.ontology = @default_ontology
        msg.in_reply_to = message.reply_with
        @cm.send(msg)

      when 'request'
        handle_request(message)
    end
  end
<commit_msg>storage: uncommented state restoration<commit_after>AGENT_ROOT = File.dirname(__FILE__)

require 'rubygems'
require 'active_support'
require 'systemu'
require 'sexpistol'
require "#{AGENT_ROOT}/../cm/logger.rb"
require "#{AGENT_ROOT}/../cm/agent.rb"
require "#{AGENT_ROOT}/../cm/kb.rb"
require "#{AGENT_ROOT}/../cm/cirrocumulus.rb"

# load corresponding backend
require "#{AGENT_ROOT}/storage_config.rb"
require "#{AGENT_ROOT}/#{Cirrocumulus::platform}/#{STORAGE_BACKEND}/storage_node.rb"

require "#{AGENT_ROOT}/storage_db.rb"

class StorageAgent < Agent
  def initialize(cm)
    super(cm)
    @default_ontology = 'cirrocumulus-storage'
  end
  
  def restore_state()
    StorageNode.list_disks().each do |disk_number|
      export_is_up = StorageNode.is_exported?(disk_number)
      export_should_be_up = AgentState.export_should_be_up?(disk_number)
      
      if export_should_be_up && !export_is_up
        Log4r::Logger['agent'].info "bringing up export #{disk_number}"
        StorageNode.add_export(disk_number, 0)
      elsif !export_should_be_up && export_is_up
        Log4r::Logger['agent'].info "shutting down export #{disk_number}"
        StorageNode.remove_export(disk_number)
      end
    end
    
    Log4r::Logger['agent'].info "restored agent state"
  end

  def handle(message, kb)
    s = Sexpistol.new
    case message.act
      when 'query-ref'
        msg = query(message.content)
        msg.receiver = message.sender
        msg.ontology = @default_ontology
        msg.in_reply_to = message.reply_with
        @cm.send(msg)

      when 'query-if'
        msg = query_if(message.content)
        msg.receiver = message.sender
        msg.ontology = @default_ontology
        msg.in_reply_to = message.reply_with
        @cm.send(msg)

      when 'request'
        handle_request(message)
    end
  end

{'fraction_non_alphanumeric': 0.1196725938470223, 'fraction_numerical': 0.0019757267852102737, 'mean_word_length': 3.3378212974296204, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, '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': '2061343', 'n_tokens_mistral': 1200, 'n_tokens_neox': 1192, 'n_words': 210}