<commit_before>package com.twitter.finagle.test

import java.net.InetSocketAddress

import org.jboss.netty.buffer._
import org.jboss.netty.channel._
import org.jboss.netty.handler.codec.http._

import net.lag.configgy.{Configgy, RuntimeEnvironment}

import com.twitter.ostrich
import com.twitter.finagle.builder._

object ServerTest extends ostrich.Service {
  class Handler extends SimpleChannelUpstreamHandler {
    override def messageReceived(ctx: ChannelHandlerContext, e: MessageEvent) {
      val response = new DefaultHttpResponse(HttpVersion.HTTP_1_1, HttpResponseStatus.OK)
      response.setHeader("Content-Type", "text/plain")
      response.setContent(ChannelBuffers.wrappedBuffer("Mission accomplished".getBytes))
      e.getChannel.write(response).addListener(ChannelFutureListener.CLOSE)
    }
  }

  def main(args: Array[String]) {
    val runtime = new RuntimeEnvironment(getClass)
    runtime.load(args)
    val config = Configgy.config

    ostrich.ServiceTracker.register(this)
    ostrich.ServiceTracker.startAdmin(config, runtime)

    val pf = new ChannelPipelineFactory {
      def getPipeline = {
        val pipeline = Channels.pipeline
        pipeline.addLast("handler", new Handler)
        pipeline
      }
    }
    val bs =
      ServerBuilder()
       .codec(Http)
       .reportTo(Ostrich())
       .pipelineFactory(pf)
       .build

    val addr = new InetSocketAddress(8888)
    println("HTTP demo running on %s".format(addr))
    bs.bind(addr)
  }

  def quiesce() = ()
  def shutdown() = ()
}<commit_msg>scala server test w/ stub interface.<commit_after>package com.twitter.finagle.test

import java.net.InetSocketAddress

import org.jboss.netty.buffer._
import org.jboss.netty.channel._
import org.jboss.netty.handler.codec.http._

import net.lag.configgy.{Configgy, RuntimeEnvironment}

import com.twitter.ostrich
import com.twitter.finagle.builder._
import com.twitter.finagle.stub._

import com.twitter.util.Future

object ServerTest extends ostrich.Service {
  class Handler extends SimpleChannelUpstreamHandler {
    override def messageReceived(ctx: ChannelHandlerContext, e: MessageEvent) {
      val response = new DefaultHttpResponse(HttpVersion.HTTP_1_1, HttpResponseStatus.OK)
      response.setHeader("Content-Type", "text/plain")
      response.setContent(ChannelBuffers.wrappedBuffer("Mission accomplished".getBytes))
      e.getChannel.write(response).addListener(ChannelFutureListener.CLOSE)
    }
  }

  def main(args: Array[String]) {
    val runtime = new RuntimeEnvironment(getClass)
    runtime.load(args)
    val config = Configgy.config

    ostrich.ServiceTracker.register(this)
    ostrich.ServiceTracker.startAdmin(config, runtime)

    val pf = new ChannelPipelineFactory {
      def getPipeline = {
        val pipeline = Channels.pipeline
        pipeline.addLast("handler", new Handler)
        pipeline
      }
    }

    val server = new Stub[HttpRequest, HttpResponse] {
      def call(request: HttpRequest) = Future {
        val response = new DefaultHttpResponse(
          HttpVersion.HTTP_1_1, HttpResponseStatus.OK)
        response.setContent(ChannelBuffers.wrappedBuffer("yo".getBytes))
        response
      }
    }

    ServerBuilder()
     .codec(Http)
     .reportTo(Ostrich())
     .stub(server)
     .bindTo(new InetSocketAddress(10000))
     .build
  }

  def quiesce() = ()
  def shutdown() = ()
}
{'fraction_non_alphanumeric': 0.09976387249114523, 'fraction_numerical': 0.004427390791027155, 'mean_word_length': 3.57972972972973, 'pattern_counts': {'":': 0, '<': 3, '<?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': '5623787', 'n_tokens_mistral': 1021, 'n_tokens_neox': 991, 'n_words': 194}