0% found this document useful (0 votes)
3 views3 pages

Scala Server Pages Implementation Guide

The document describes a DataServer class in Scala that can create a server, add endpoints, start and stop the server, and serve data. It defines methods to load data and serve it in JSON format. It also describes a PipelineTestTrait for testing pipelines, a Pipeline class to run script actions and build URIs, and a package object for Squishly with various options and filters. Code snippets are provided for related classes like PipelineBuilder, ScriptBuilder, and AppendTest.

Uploaded by

Rajeev Kumar
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views3 pages

Scala Server Pages Implementation Guide

The document describes a DataServer class in Scala that can create a server, add endpoints, start and stop the server, and serve data. It defines methods to load data and serve it in JSON format. It also describes a PipelineTestTrait for testing pipelines, a Pipeline class to run script actions and build URIs, and a package object for Squishly with various options and filters. Code snippets are provided for related classes like PipelineBuilder, ScriptBuilder, and AppendTest.

Uploaded by

Rajeev Kumar
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

STEP-01

class [Link]{
def newServer(): Server = {
doGet()
parseJson()
readRequest()
writeResponse()
writeJson()
}
addGetEndpoint(endPoint: EndPoint)
addPostEndpoint(endPoint: EndPoint)
stop()
start()
serve()
serveWithSize()
serveIncorrectMetadataSize()
loadData()
serveRandom()
addDelayPerRow()
serveData()
uri()
publishUri()
}

def serve(columns: Seq[String], data: Seq[Any]*): String = {


serveData(columns, [Link], data, None)
}
def serve(columns: Seq[String], dsId:String, data: Seq[Any]*): String = {
serveData(columns, [Link], data, Some(dsId))
}

private def serveData(columns: Seq[String], size: Int, data: Seq[Seq[Any]], dsId:Option[String]


= None): String = {
val metadata = ("count" -> size) ~
("metadata" -> (
("@class" -> "[Link]") ~
("name" -> "Dont Really Care") ~
("columns" -> [Link](c => {
("@class" -> "[Link]") ~
("name" -> c) ~
("colType" -> "String")
}))))
val datasetId = [Link]([Link]().toString)
[Link](datasetId, (metadata, [Link](_.map({
case null => JNull
case s: String => JString(s)
case i: Int => JInt(i)
case d: Double => JDouble(d)
case c: Char => JString([Link])
case b: Boolean => JBool(b)
case d: DateTime => JObject("type" -> JString("DateTime"), "value" -> JString([Link]))
}))))
if (server == null) start()
datasetId
}

STEP-02
trait PipelineTestTrait extends FreeSpec with Matchers with Assertions with
BeforeAndAfterEachTestData with BeforeAndAfterAll

beforeAll(){[Link](appender)}
beforeEach(td:TestData){dataServer = [Link]()}
afterEach(td:TestData){[Link]()}

STEP-03

[Link] extends Eventually{


def runScript[T <: ExecutionResult](action: ExecutableScriptAction[T]): T = {
runAPI(uri, action, makeDummyRequestParams())
}

def uri = [Link]()


def uriBuilder = new
URIBuilder().setScheme("http").setHost([Link]).setPort(CommonTestCons
[Link])

parseView()
parseFacet()
parseFacet30()
parseHistogram2()
parseRow()
parseProfiles()
}

STEP-04 ::: squishly/[Link]

package object squishly {


defaultAuthToken
valueOrNot()
stringFilter()
numberFilter()
datetimeFilter()
percentilesFilter()
sourcesFilter()
libraryOptions()
datagenOptions()
script()
getColNameForPivot()
quoted()
trait CanBuildPipelinesAndActions{}
class ProfileOptions {}
class SquishlyLibraryImportOptions()
class SquishlyDirectImportOptions()
}

STEP-06 ::: [Link] and [Link]

C:\pr_testing\pax\shared\pipeline-
client\src\main\scala\com\paxata\pipeline\generator\[Link]

C:\pr_testing\pax\shared\pipeline-
client\src\main\scala\com\paxata\pipeline\generator\[Link]

C:\pr_testing\pax\shared\pipeline-
client\src\main\scala\com\paxata\pipeline\generator\impl\action\[Link]
STEP-07

class AppendTest extends PipelineTestTrait {


val baseTableId = [Link](baseTableColumns,Seq("Mickey"))
val appendTableId = [Link](appendTableColumns,Seq("Donald"))
val view = runScript(script(appendPipelineId, pna => {
val bId = "importBaseTablePipeline"
[Link](bId)(steps => {
[Link](baseTableColumns, libraryOptions(baseTableId,dataServer))
})

C:\pr_testing\pax\integration-
tests\squishly\src\test\scala\com\paxata\pipeline\squishly\[Link]
At line no. 77, val server = new Server(new InetSocketAddress("[Link]",5000))

C:\pr_testing\pax\integration-
tests\squishly\src\test\scala\com\paxata\pipeline\squishly\[Link]
At line no. 38, def PipelineHost = "[Link]"
At line no. 40, def PipelinePort:Int = 8800

C:\pr_testing\pax\integration-
tests\squishly\src\test\scala\com\paxata\pipeline\squishly\[Link]
def uriBuilder = new
URIBuilder().setScheme("http").setHost([Link]).setPort(CommonTestCons
[Link]).setCustomQuery("?pp_numOfExecutors=1&pp_inactivityThresholdMinutes=3&pp_pip
elineUniqueId=QSSD")

C:\pr_testing\pax\shared\pipeline-
client\src\main\scala\com\paxata\pipeline\generator\[Link]
replace /get with get

You might also like