当前位置: 首页>>代码示例>>Scala>>正文


Scala Set类代码示例

本文整理汇总了Scala中java.util.Set的典型用法代码示例。如果您正苦于以下问题:Scala Set类的具体用法?Scala Set怎么用?Scala Set使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Set类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Scala代码示例。

示例1: TravisCommand

//设置package包名称以及导入依赖的类
package com.atomist.rug.commands.travis

import com.atomist.rug.kind.service.ServicesMutableView
import com.atomist.rug.kind.travis.{RealTravisEndpoints, TravisAPIEndpoint, TravisEndpoints}
import com.atomist.rug.spi.Command
import org.springframework.http.HttpHeaders
import java.util.{Collections, Set}

class TravisCommand extends Command[ServicesMutableView] {

  override def nodeTypes: Set[String] = Collections.singleton("Services")

  override def name: String = "travis"

  override def invokeOn(treeNode: ServicesMutableView): AnyRef = {
    new TravisOperations(new RealTravisEndpoints)
  }
}

class TravisOperations(travisEndpoints: TravisEndpoints) {

  def restartBuild(buildId: Int, org: String, token: String): TravisStatus = {
    val api: TravisAPIEndpoint = TravisAPIEndpoint.stringToTravisEndpoint(org)
    val travisToken: String = travisEndpoints.postAuthGitHub(api, token)
    val headers: HttpHeaders = TravisEndpoints.authHeaders(api, travisToken)
    try {
      travisEndpoints.postRestartBuild(api, headers, buildId)
      new TravisStatus(true, s"Successfully restarted build `${buildId}` on Travis CI")
    }
    catch {
      case e: Exception => new TravisStatus(false, e.getMessage)
    }
  }
}

case class TravisStatus(success: Boolean = true, message: String = "") 
开发者ID:atomist-recycling,项目名称:travis-rug-type,代码行数:37,代码来源:TravisCommand.scala

示例2: Dynomite

//设置package包名称以及导入依赖的类
package com.advancedspark.serving.spark

import com.netflix.dyno.jedis._
import com.netflix.dyno.connectionpool.Host
import com.netflix.dyno.connectionpool.HostSupplier
import com.netflix.dyno.connectionpool.TokenMapSupplier
import com.netflix.dyno.connectionpool.impl.lb.HostToken
import com.netflix.dyno.connectionpool.exception.DynoException
import com.netflix.dyno.connectionpool.impl.ConnectionPoolConfigurationImpl
import com.netflix.dyno.connectionpool.impl.ConnectionContextImpl
import com.netflix.dyno.connectionpool.impl.OperationResultImpl
import com.netflix.dyno.connectionpool.impl.utils.ZipUtils

import scala.collection.JavaConversions._
import java.util.Collections
import java.util.Collection
import java.util.Set
import java.util.List

object Dynomite {
  val localhostHost = new Host("127.0.0.1", Host.Status.Up)
  val localhostToken = new HostToken(100000L, localhostHost)

  val localhostHostSupplier = new HostSupplier() {
    @Override
    def getHosts(): Collection[Host] = {
      Collections.singletonList(localhostHost)
    }
  }

  val localhostTokenMapSupplier = new TokenMapSupplier() {
    @Override
    def getTokens(activeHosts: Set[Host]): List[HostToken] = {
      Collections.singletonList(localhostToken)
    }

    @Override
    def getTokenForHost(host: Host, activeHosts: Set[Host]): HostToken = {
      return localhostToken
    }
  }

  val redisPort = 6379
  val client = new DynoJedisClient.Builder()
             .withApplicationName("pipeline")
             .withDynomiteClusterName("pipeline-dynomite")
             .withHostSupplier(localhostHostSupplier)
             .withCPConfig(new ConnectionPoolConfigurationImpl("localhostTokenMapSupplier")
                .withTokenSupplier(localhostTokenMapSupplier))
             .withPort(redisPort)
             .build()
} 
开发者ID:frankiegu,项目名称:serve.ml,代码行数:53,代码来源:Dynomite.scala


注:本文中的java.util.Set类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。