Skip to content

Commit

Permalink
Use Jackson for JSON de/serialization
Browse files Browse the repository at this point in the history
This involves a major refactor of all message representations.
The main motivation for this change is to simplify the logic to
enforce type safety, such that we no longer depend on the behavior
of all the scala class magic we used to rely on.

This commit also introduces a differentiation between request
and response messages to provide further type safety. This would
have introduced much additional complexity without the refactor.
  • Loading branch information
Andrew Or committed Jan 29, 2015
1 parent d7a1f9f commit df90e8b
Show file tree
Hide file tree
Showing 23 changed files with 910 additions and 1,071 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.apache.spark.deploy.rest

class DriverStatusRequest extends SubmitRestProtocolRequest {
protected override val action = SubmitRestProtocolAction.DRIVER_STATUS_REQUEST
private val driverId = new SubmitRestProtocolField[String]

def getDriverId: String = driverId.toString
def setDriverId(s: String): this.type = setField(driverId, s)

override def validate(): Unit = {
super.validate()
assertFieldIsSet(driverId, "driver_id")
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.apache.spark.deploy.rest

class DriverStatusResponse extends SubmitRestProtocolResponse {
protected override val action = SubmitRestProtocolAction.DRIVER_STATUS_RESPONSE
private val driverId = new SubmitRestProtocolField[String]
private val success = new SubmitRestProtocolField[Boolean]
private val driverState = new SubmitRestProtocolField[String]
private val workerId = new SubmitRestProtocolField[String]
private val workerHostPort = new SubmitRestProtocolField[String]

def getDriverId: String = driverId.toString
def getSuccess: String = success.toString
def getDriverState: String = driverState.toString
def getWorkerId: String = workerId.toString
def getWorkerHostPort: String = workerHostPort.toString

def setDriverId(s: String): this.type = setField(driverId, s)
def setSuccess(s: String): this.type = setBooleanField(success, s)
def setDriverState(s: String): this.type = setField(driverState, s)
def setWorkerId(s: String): this.type = setField(workerId, s)
def setWorkerHostPort(s: String): this.type = setField(workerHostPort, s)

override def validate(): Unit = {
super.validate()
assertFieldIsSet(driverId, "driver_id")
assertFieldIsSet(success, "success")
}
}

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.apache.spark.deploy.rest

class ErrorResponse extends SubmitRestProtocolResponse {
protected override val action = SubmitRestProtocolAction.ERROR
override def validate(): Unit = {
super.validate()
assertFieldIsSet(message, "message")
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.apache.spark.deploy.rest

class KillDriverRequest extends SubmitRestProtocolRequest {
protected override val action = SubmitRestProtocolAction.KILL_DRIVER_REQUEST
private val driverId = new SubmitRestProtocolField[String]

def getDriverId: String = driverId.toString
def setDriverId(s: String): this.type = setField(driverId, s)

override def validate(): Unit = {
super.validate()
assertFieldIsSet(driverId, "driver_id")
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.apache.spark.deploy.rest

class KillDriverResponse extends SubmitRestProtocolResponse {
protected override val action = SubmitRestProtocolAction.KILL_DRIVER_RESPONSE
private val driverId = new SubmitRestProtocolField[String]
private val success = new SubmitRestProtocolField[Boolean]

def getDriverId: String = driverId.toString
def getSuccess: String = success.toString

def setDriverId(s: String): this.type = setField(driverId, s)
def setSuccess(s: String): this.type = setBooleanField(success, s)

override def validate(): Unit = {
super.validate()
assertFieldIsSet(driverId, "driver_id")
assertFieldIsSet(success, "success")
}
}
Loading

0 comments on commit df90e8b

Please sign in to comment.