add the ability to ask for multiple instances from JS page

This commit is contained in:
Stephen Birarda 2013-09-17 11:48:08 -07:00
parent 0e19d9a53a
commit 76df707e31
5 changed files with 39 additions and 10 deletions

View file

@ -36,11 +36,22 @@ body {
}
#deploy-button {
background-color: #0DFFBB;
right: 0px;
right: 85px;
}
#deploy-button:hover {
background-color: #28FF57;
}
#instance-field {
position: absolute;
right: 20px;
top: 40px;
}
#instance-field input {
width: 80px;
}
#stop-button {
background-color: #CC1F00;
right: 0px;

View file

@ -14,6 +14,9 @@
Run
</a>
</div>
<div class='big-field' id='instance-field'>
<input type='text' name='instances' placeholder='# of instances'>
</div>
<!-- %div#stop-button.big-button -->
</body>
</html>

View file

@ -20,6 +20,11 @@ $(document).ready(function(){
// add the script
+ script + '\r\n'
+ '--' + boundary + '--';
var headers = {};
if ($('#instance-field input').val()) {
headers['ASSIGNMENT-INSTANCES'] = $('#instance-field input').val();
}
// post form to assignment in order to create an assignment
$.ajax({
@ -27,6 +32,7 @@ $(document).ready(function(){
data: body,
type: "POST",
url: "/assignment",
headers: headers,
success: function (data, status) {
console.log(data);
console.log(status);

View file

@ -313,17 +313,18 @@ int main(int argc, const char* argv[]) {
broadcastPacket,
numHeaderBytes + numAssignmentBytes);
// remove the assignment from the queue
::assignmentQueue.erase(assignment);
if ((*assignment)->getType() == Assignment::AgentType) {
// if this is a script assignment we need to delete it to avoid a memory leak
// or if there is more than one instance to send out, simpy decrease the number of instances
if ((*assignment)->getNumberOfInstances() > 1) {
(*assignment)->decrementNumberOfInstances();
} else {
::assignmentQueue.erase(assignment);
delete *assignment;
}
} else {
// remove the assignment from the queue
::assignmentQueue.erase(assignment);
}
// stop looping, we've handed out an assignment
@ -351,12 +352,18 @@ int main(int argc, const char* argv[]) {
nodeList->sendAssignment(*(*assignment));
// remove the assignment from the queue
::assignmentQueue.erase(assignment);
if ((*assignment)->getType() == Assignment::AgentType) {
// if this is a script assignment we need to delete it to avoid a memory leak
delete *assignment;
// or if there is more than one instance to send out, simpy decrease the number of instances
if ((*assignment)->getNumberOfInstances() > 1) {
(*assignment)->decrementNumberOfInstances();
} else {
::assignmentQueue.erase(assignment);
delete *assignment;
}
} else {
// remove the assignment from the queue
::assignmentQueue.erase(assignment);
}
// stop looping, we've handed out an assignment

View file

@ -21,7 +21,8 @@ Assignment::Assignment(Assignment::Command command, Assignment::Type type, Assig
_type(type),
_location(location),
_attachedPublicSocket(NULL),
_attachedLocalSocket(NULL)
_attachedLocalSocket(NULL),
_numberOfInstances(1)
{
// set the create time on this assignment
gettimeofday(&_time, NULL);
@ -35,7 +36,8 @@ Assignment::Assignment(Assignment::Command command, Assignment::Type type, Assig
Assignment::Assignment(const unsigned char* dataBuffer, int numBytes) :
_location(GlobalLocation),
_attachedPublicSocket(NULL),
_attachedLocalSocket(NULL)
_attachedLocalSocket(NULL),
_numberOfInstances(1)
{
// set the create time on this assignment
gettimeofday(&_time, NULL);