本文整理汇总了Scala中java.net.UnknownHostException类的典型用法代码示例。如果您正苦于以下问题:Scala UnknownHostException类的具体用法?Scala UnknownHostException怎么用?Scala UnknownHostException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了UnknownHostException类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Scala代码示例。
示例1: RemoteServer
//设置package包名称以及导入依赖的类
package org.argus.jc.incremental.jawa
package remote
import java.net.{ConnectException, InetAddress, UnknownHostException}
import org.argus.jc.incremental.jawa.data.{CompilationData, CompilerData}
import org.jetbrains.jps.incremental.ModuleLevelBuilder.ExitCode
class RemoteServer(val address: InetAddress, val port: Int) extends Server with RemoteResourceOwner {
def compile(compilerData: CompilerData, compilationData: CompilationData, client: Client): ExitCode = {
val arguments = Arguments(compilerData, compilationData).asStrings
try {
send(serverAlias, arguments, client)
ExitCode.OK
} catch {
case e: ConnectException =>
val firstLine = s"Cannot connect to compile server at ${address.toString}:$port"
val secondLine = "Trying to compile without it"
val message = s"$firstLine\n$secondLine"
client.warning(message)
client.debug(s"$firstLine\n${e.toString}\n${e.getStackTrace.mkString("\n")}")
JawaBuilder.localServer.compile(compilerData, compilationData, client)
case e: UnknownHostException =>
val message = "Unknown IP address of compile server host: " + address.toString
client.error(message)
client.debug(s"$message\n${e.toString}\n${e.getStackTrace.mkString("\n")}")
ExitCode.ABORT
}
}
}
开发者ID:arguslab,项目名称:argus-cit-intellij,代码行数:33,代码来源:RemoteServer.scala
示例2: InetAddressDnsResolver
//设置package包名称以及导入依赖的类
package akka.io
import java.net.{ UnknownHostException, InetAddress }
import java.util.concurrent.TimeUnit
import akka.actor.Actor
import com.typesafe.config.Config
import scala.collection.immutable
class InetAddressDnsResolver(cache: SimpleDnsCache, config: Config) extends Actor {
val positiveTtl = config.getDuration("positive-ttl", TimeUnit.MILLISECONDS)
val negativeTtl = config.getDuration("negative-ttl", TimeUnit.MILLISECONDS)
override def receive = {
case Dns.Resolve(name) ?
val answer = cache.cached(name) match {
case Some(a) ? a
case None ?
try {
val answer = Dns.Resolved(name, InetAddress.getAllByName(name))
cache.put(answer, positiveTtl)
answer
} catch {
case e: UnknownHostException ?
val answer = Dns.Resolved(name, immutable.Seq.empty, immutable.Seq.empty)
cache.put(answer, negativeTtl)
answer
}
}
sender() ! answer
}
}
开发者ID:rorygraves,项目名称:perf_tester,代码行数:34,代码来源:InetAddressDnsResolver.scala
示例3: InetAddressDnsResolver
//设置package包名称以及导入依赖的类
package akka.io
import java.net.{ UnknownHostException, InetAddress }
import java.util.concurrent.TimeUnit
import akka.actor.Actor
import com.typesafe.config.Config
import scala.collection.immutable
class InetAddressDnsResolver(cache: SimpleDnsCache, config: Config) extends Actor {
val positiveTtl: Long = config.getDuration("positive-ttl", TimeUnit.MILLISECONDS)
val negativeTtl: Long = config.getDuration("negative-ttl", TimeUnit.MILLISECONDS)
override def receive: PartialFunction[Any, Unit] = {
case Dns.Resolve(name) ?
val answer = cache.cached(name) match {
case Some(a) ? a
case None ?
try {
val answer = Dns.Resolved(name, InetAddress.getAllByName(name))
cache.put(answer, positiveTtl)
answer
} catch {
case e: UnknownHostException ?
val answer = Dns.Resolved(name, immutable.Seq.empty, immutable.Seq.empty)
cache.put(answer, negativeTtl)
answer
}
}
sender() ! answer
}
}
开发者ID:rorygraves,项目名称:perf_tester,代码行数:34,代码来源:InetAddressDnsResolver.scala
示例4: ScenarioSetup
//设置package包名称以及导入依赖的类
package se.kth.app.sim
import java.net.InetAddress
import java.net.UnknownHostException
import se.kth.system.SystemSetup
import se.sics.ktoolbox.util.identifiable.BasicBuilders
import se.sics.ktoolbox.util.identifiable.BasicIdentifiers
import se.sics.ktoolbox.util.identifiable.overlay.OverlayId
import se.sics.ktoolbox.util.network.KAddress
import se.sics.ktoolbox.util.network.basic.BasicAddress
import se.sics.ktoolbox.util.network.nat.NatAwareAddressImpl
object ScenarioSetup {
val scenarioSeed: Long = 1234
val appPort: Int = 12345
var bootstrapServer: KAddress = null
var croupierOId: OverlayId = null
{
croupierOId = SystemSetup.setup()
val bootstrapId = BasicIdentifiers.nodeId(new BasicBuilders.IntBuilder(0))
try {
bootstrapServer = NatAwareAddressImpl.open(new BasicAddress(InetAddress.getByName("193.0.0.1"), appPort, bootstrapId));
}
catch {
case ex: UnknownHostException => throw new RuntimeException(ex)
}
}
def getNodeAdr(nodeIp: String, baseNodeId: Int): KAddress = {
try {
val nodeId = BasicIdentifiers.nodeId(new BasicBuilders.IntBuilder(baseNodeId))
NatAwareAddressImpl.open(new BasicAddress(InetAddress.getByName(nodeIp), appPort, nodeId))
} catch {
case ex: UnknownHostException => {
throw new RuntimeException(ex)
}
}
}
def getNodeSeed(nodeId: Int): Long = scenarioSeed + nodeId
}
开发者ID:reginbald,项目名称:p2p-crdt,代码行数:46,代码来源:ScenarioSetup.scala
示例5: ConnectHandler
//设置package包名称以及导入依赖的类
package tk.dasb.handler
import java.net.{InetSocketAddress, UnknownHostException}
import io.netty.bootstrap.Bootstrap
import io.netty.channel._
import io.netty.channel.socket.SocketChannel
import io.netty.channel.socket.nio.NioSocketChannel
import tk.dasb.codec.{ReplyEncoder, ReqDecoder}
import tk.dasb.protocol.{Reply, Req}
import tk.dasb.util.{FutureConv, Log}
class ConnectHandler(val req: Req) extends ChannelInboundHandlerAdapter with Log with FutureConv{
var closeAll: ()=>Any = ()=>{}
override def exceptionCaught(ctx: ChannelHandlerContext, cause: Throwable): Unit = closeAll()
override def channelInactive(ctx: ChannelHandlerContext): Unit = closeAll()
override def channelActive(ctx: ChannelHandlerContext): Unit = {
val b = new Bootstrap
b.group(ctx.channel.eventLoop).channel(classOf[NioSocketChannel])
.option[java.lang.Boolean](ChannelOption.SO_KEEPALIVE, true).option[java.lang.Boolean](ChannelOption.TCP_NODELAY, true)
.handler(new ChannelInitializer[SocketChannel] {
override def initChannel(ch: SocketChannel): Unit = {}
})
log.debug("connecting:{}", req.dstAddress)
b.connect(req.dstAddress).success{
connFuture =>
log.debug("connect success")
ctx.writeAndFlush(Reply.connSuccess(ctx.channel.localAddress.asInstanceOf[InetSocketAddress])).success{
writeFuture =>
closeAll = ()=> {
ctx.close()
connFuture.channel().close()
}
ctx.pipeline.remove(classOf[ReqDecoder])
ctx.pipeline.remove(classOf[ReqHandler])
ctx.pipeline.remove(classOf[ReplyEncoder])
ctx.pipeline.remove(ConnectHandler.this)
ctx.pipeline.addLast(new PipHandler(connFuture.channel)) // client -> proxy
connFuture.channel.pipeline.addFirst(new PipHandler(writeFuture.channel)) // remote -> proxy
}
}.failed{
connFuture=>
connFuture.cause match {
case _: UnknownHostException =>
ctx.writeAndFlush(Reply.failed(req.dstAddress, Reply.FAILURE_HOST_UNREACH)).Close
case _ =>
ctx.writeAndFlush(Reply.failed(req.dstAddress, Reply.FAILURE_SERVER)).Close
}
}
}
}
开发者ID:xqdxqd,项目名称:tiny-sock5-server,代码行数:61,代码来源:ConnectHandler.scala
示例6: StringNetworkOps
//设置package包名称以及导入依赖的类
package com.avsystem.scex.util
import java.net.{InetAddress, UnknownHostException}
import com.avsystem.scex.util.function.NetFunctions
final class StringNetworkOps(private val wrapped: String) extends AnyVal {
def isIpInSubnet(subnetWithMask: String): Boolean =
NetFunctions.isIpInSubnet(wrapped, subnetWithMask)
def isIpInSubnetWithMask(subnet: String, mask: String): Boolean =
NetFunctions.isIpInSubnetWithMask(wrapped, subnet, mask)
def stripMac: String = NetFunctions.stripMac(wrapped)
def isIp: Boolean = NetFunctions.isIp(wrapped)
def isIps: Boolean = NetFunctions.isIps(wrapped)
def isMac: Boolean = NetFunctions.isMac(wrapped)
def compareAsIpTo(ip: String): Integer = try {
val adr1 = InetAddress.getByName(wrapped)
val adr2 = InetAddress.getByName(ip)
val inetAddressComparator = new NetFunctions.InetAddressComparator
inetAddressComparator.compare(adr1, adr2)
} catch {
case _: UnknownHostException => null
}
}
开发者ID:AVSystem,项目名称:scex,代码行数:28,代码来源:StringNetworkOps.scala
注:本文中的java.net.UnknownHostException类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论