Page MenuHomePhabricator

D14153.diff
No OneTemporary

D14153.diff

diff --git a/resources/sql/autopatches/20150924.drydock.status.1.sql b/resources/sql/autopatches/20150924.drydock.status.1.sql
new file mode 100644
--- /dev/null
+++ b/resources/sql/autopatches/20150924.drydock.status.1.sql
@@ -0,0 +1,39 @@
+ALTER TABLE {$NAMESPACE}_drydock.drydock_lease
+ CHANGE status status VARCHAR(32) NOT NULL COLLATE {$COLLATE_TEXT};
+
+UPDATE {$NAMESPACE}_drydock.drydock_lease
+ SET status = 'pending' WHERE status = '0';
+
+UPDATE {$NAMESPACE}_drydock.drydock_lease
+ SET status = 'acquired' WHERE status = '5';
+
+UPDATE {$NAMESPACE}_drydock.drydock_lease
+ SET status = 'active' WHERE status = '1';
+
+UPDATE {$NAMESPACE}_drydock.drydock_lease
+ SET status = 'released' WHERE status = '2';
+
+UPDATE {$NAMESPACE}_drydock.drydock_lease
+ SET status = 'broken' WHERE status = '3';
+
+UPDATE {$NAMESPACE}_drydock.drydock_lease
+ SET status = 'destroyed' WHERE status = '4';
+
+
+ALTER TABLE {$NAMESPACE}_drydock.drydock_resource
+ CHANGE status status VARCHAR(32) NOT NULL COLLATE {$COLLATE_TEXT};
+
+UPDATE {$NAMESPACE}_drydock.drydock_resource
+ SET status = 'pending' WHERE status = '0';
+
+UPDATE {$NAMESPACE}_drydock.drydock_resource
+ SET status = 'active' WHERE status = '1';
+
+UPDATE {$NAMESPACE}_drydock.drydock_resource
+ SET status = 'released' WHERE status = '2';
+
+UPDATE {$NAMESPACE}_drydock.drydock_resource
+ SET status = 'broken' WHERE status = '3';
+
+UPDATE {$NAMESPACE}_drydock.drydock_resource
+ SET status = 'destroyed' WHERE status = '4';
diff --git a/src/applications/drydock/blueprint/DrydockAlmanacServiceHostBlueprintImplementation.php b/src/applications/drydock/blueprint/DrydockAlmanacServiceHostBlueprintImplementation.php
--- a/src/applications/drydock/blueprint/DrydockAlmanacServiceHostBlueprintImplementation.php
+++ b/src/applications/drydock/blueprint/DrydockAlmanacServiceHostBlueprintImplementation.php
@@ -252,8 +252,8 @@
->withStatuses(
array(
DrydockResourceStatus::STATUS_PENDING,
- DrydockResourceStatus::STATUS_OPEN,
- DrydockResourceStatus::STATUS_CLOSED,
+ DrydockResourceStatus::STATUS_ACTIVE,
+ DrydockResourceStatus::STATUS_RELEASED,
))
->execute();
diff --git a/src/applications/drydock/constants/DrydockLeaseStatus.php b/src/applications/drydock/constants/DrydockLeaseStatus.php
--- a/src/applications/drydock/constants/DrydockLeaseStatus.php
+++ b/src/applications/drydock/constants/DrydockLeaseStatus.php
@@ -2,12 +2,12 @@
final class DrydockLeaseStatus extends DrydockConstants {
- const STATUS_PENDING = 0;
- const STATUS_ACQUIRED = 5;
- const STATUS_ACTIVE = 1;
- const STATUS_RELEASED = 2;
- const STATUS_BROKEN = 3;
- const STATUS_DESTROYED = 4;
+ const STATUS_PENDING = 'pending';
+ const STATUS_ACQUIRED = 'acquired';
+ const STATUS_ACTIVE = 'active';
+ const STATUS_RELEASED = 'released';
+ const STATUS_BROKEN = 'broken';
+ const STATUS_DESTROYED = 'destroyed';
public static function getNameForStatus($status) {
$map = array(
diff --git a/src/applications/drydock/constants/DrydockResourceStatus.php b/src/applications/drydock/constants/DrydockResourceStatus.php
--- a/src/applications/drydock/constants/DrydockResourceStatus.php
+++ b/src/applications/drydock/constants/DrydockResourceStatus.php
@@ -2,19 +2,19 @@
final class DrydockResourceStatus extends DrydockConstants {
- const STATUS_PENDING = 0;
- const STATUS_OPEN = 1;
- const STATUS_CLOSED = 2;
- const STATUS_BROKEN = 3;
- const STATUS_DESTROYED = 4;
+ const STATUS_PENDING = 'pending';
+ const STATUS_ACTIVE = 'active';
+ const STATUS_RELEASED = 'released';
+ const STATUS_BROKEN = 'broken';
+ const STATUS_DESTROYED = 'destroyed';
public static function getNameForStatus($status) {
$map = array(
- self::STATUS_PENDING => pht('Pending'),
- self::STATUS_OPEN => pht('Open'),
- self::STATUS_CLOSED => pht('Closed'),
- self::STATUS_BROKEN => pht('Broken'),
- self::STATUS_DESTROYED => pht('Destroyed'),
+ self::STATUS_PENDING => pht('Pending'),
+ self::STATUS_ACTIVE => pht('Active'),
+ self::STATUS_RELEASED => pht('Released'),
+ self::STATUS_BROKEN => pht('Broken'),
+ self::STATUS_DESTROYED => pht('Destroyed'),
);
return idx($map, $status, pht('Unknown'));
@@ -23,8 +23,8 @@
public static function getAllStatuses() {
return array(
self::STATUS_PENDING,
- self::STATUS_OPEN,
- self::STATUS_CLOSED,
+ self::STATUS_ACTIVE,
+ self::STATUS_RELEASED,
self::STATUS_BROKEN,
self::STATUS_DESTROYED,
);
diff --git a/src/applications/drydock/query/DrydockLeaseQuery.php b/src/applications/drydock/query/DrydockLeaseQuery.php
--- a/src/applications/drydock/query/DrydockLeaseQuery.php
+++ b/src/applications/drydock/query/DrydockLeaseQuery.php
@@ -98,7 +98,7 @@
if ($this->statuses !== null) {
$where[] = qsprintf(
$conn,
- 'status IN (%Ld)',
+ 'status IN (%Ls)',
$this->statuses);
}
diff --git a/src/applications/drydock/query/DrydockResourceSearchEngine.php b/src/applications/drydock/query/DrydockResourceSearchEngine.php
--- a/src/applications/drydock/query/DrydockResourceSearchEngine.php
+++ b/src/applications/drydock/query/DrydockResourceSearchEngine.php
@@ -73,7 +73,7 @@
'statuses',
array(
DrydockResourceStatus::STATUS_PENDING,
- DrydockResourceStatus::STATUS_OPEN,
+ DrydockResourceStatus::STATUS_ACTIVE,
));
case 'all':
return $query;
diff --git a/src/applications/drydock/storage/DrydockLease.php b/src/applications/drydock/storage/DrydockLease.php
--- a/src/applications/drydock/storage/DrydockLease.php
+++ b/src/applications/drydock/storage/DrydockLease.php
@@ -60,7 +60,7 @@
'attributes' => self::SERIALIZATION_JSON,
),
self::CONFIG_COLUMN_SCHEMA => array(
- 'status' => 'uint32',
+ 'status' => 'text32',
'until' => 'epoch?',
'resourceType' => 'text128',
'ownerPHID' => 'phid?',
diff --git a/src/applications/drydock/storage/DrydockResource.php b/src/applications/drydock/storage/DrydockResource.php
--- a/src/applications/drydock/storage/DrydockResource.php
+++ b/src/applications/drydock/storage/DrydockResource.php
@@ -30,14 +30,15 @@
self::CONFIG_COLUMN_SCHEMA => array(
'name' => 'text255',
'ownerPHID' => 'phid?',
- 'status' => 'uint32',
+ 'status' => 'text32',
'type' => 'text64',
),
self::CONFIG_KEY_SCHEMA => array(
- 'key_phid' => null,
- 'phid' => array(
- 'columns' => array('phid'),
- 'unique' => true,
+ 'key_type' => array(
+ 'columns' => array('type', 'status'),
+ ),
+ 'key_blueprint' => array(
+ 'columns' => array('blueprintPHID', 'status'),
),
),
) + parent::getConfiguration();
@@ -107,7 +108,7 @@
}
if ($this->activateWhenAllocated) {
- $new_status = DrydockResourceStatus::STATUS_OPEN;
+ $new_status = DrydockResourceStatus::STATUS_ACTIVE;
} else {
$new_status = DrydockResourceStatus::STATUS_PENDING;
}
@@ -153,7 +154,7 @@
$this->openTransaction();
$this
- ->setStatus(DrydockResourceStatus::STATUS_OPEN)
+ ->setStatus(DrydockResourceStatus::STATUS_ACTIVE)
->save();
DrydockSlotLock::acquireLocks($this->getPHID(), $this->slotLocks);
@@ -172,7 +173,7 @@
public function canRelease() {
switch ($this->getStatus()) {
- case DrydockResourceStatus::STATUS_CLOSED:
+ case DrydockResourceStatus::STATUS_RELEASED:
case DrydockResourceStatus::STATUS_DESTROYED:
return false;
default:
diff --git a/src/applications/drydock/view/DrydockResourceListView.php b/src/applications/drydock/view/DrydockResourceListView.php
--- a/src/applications/drydock/view/DrydockResourceListView.php
+++ b/src/applications/drydock/view/DrydockResourceListView.php
@@ -29,7 +29,7 @@
case DrydockResourceStatus::STATUS_PENDING:
$item->setStatusIcon('fa-dot-circle-o yellow');
break;
- case DrydockResourceStatus::STATUS_OPEN:
+ case DrydockResourceStatus::STATUS_ACTIVE:
$item->setStatusIcon('fa-dot-circle-o green');
break;
case DrydockResourceStatus::STATUS_DESTROYED:
diff --git a/src/applications/drydock/worker/DrydockAllocatorWorker.php b/src/applications/drydock/worker/DrydockAllocatorWorker.php
--- a/src/applications/drydock/worker/DrydockAllocatorWorker.php
+++ b/src/applications/drydock/worker/DrydockAllocatorWorker.php
@@ -229,7 +229,7 @@
->withStatuses(
array(
DrydockResourceStatus::STATUS_PENDING,
- DrydockResourceStatus::STATUS_OPEN,
+ DrydockResourceStatus::STATUS_ACTIVE,
))
->execute();
diff --git a/src/applications/drydock/worker/DrydockLeaseWorker.php b/src/applications/drydock/worker/DrydockLeaseWorker.php
--- a/src/applications/drydock/worker/DrydockLeaseWorker.php
+++ b/src/applications/drydock/worker/DrydockLeaseWorker.php
@@ -34,7 +34,7 @@
throw new Exception(pht('Resource still activating.'));
}
- if ($resource_status != DrydockResourceStatus::STATUS_OPEN) {
+ if ($resource_status != DrydockResourceStatus::STATUS_ACTIVE) {
throw new PhabricatorWorkerPermanentFailureException(
pht(
'Trying to activate lease on a dead resource (in status "%s").',
diff --git a/src/applications/drydock/worker/DrydockResourceDestroyWorker.php b/src/applications/drydock/worker/DrydockResourceDestroyWorker.php
--- a/src/applications/drydock/worker/DrydockResourceDestroyWorker.php
+++ b/src/applications/drydock/worker/DrydockResourceDestroyWorker.php
@@ -12,7 +12,7 @@
$status = $resource->getStatus();
switch ($status) {
- case DrydockResourceStatus::STATUS_CLOSED:
+ case DrydockResourceStatus::STATUS_RELEASED:
case DrydockResourceStatus::STATUS_BROKEN:
break;
default:
diff --git a/src/applications/drydock/worker/DrydockResourceUpdateWorker.php b/src/applications/drydock/worker/DrydockResourceUpdateWorker.php
--- a/src/applications/drydock/worker/DrydockResourceUpdateWorker.php
+++ b/src/applications/drydock/worker/DrydockResourceUpdateWorker.php
@@ -20,7 +20,7 @@
private function updateResource(DrydockResource $resource) {
$commands = $this->loadCommands($resource->getPHID());
foreach ($commands as $command) {
- if ($resource->getStatus() != DrydockResourceStatus::STATUS_OPEN) {
+ if ($resource->getStatus() != DrydockResourceStatus::STATUS_ACTIVE) {
// Resources can't receive commands before they activate or after they
// release.
break;
@@ -46,7 +46,7 @@
}
private function releaseResource(DrydockResource $resource) {
- if ($resource->getStatus() != DrydockResourceStatus::STATUS_OPEN) {
+ if ($resource->getStatus() != DrydockResourceStatus::STATUS_ACTIVE) {
// If we had multiple release commands
// This command is only meaningful to resources in the "Open" state.
return;
@@ -57,7 +57,7 @@
$resource->openTransaction();
$resource
- ->setStatus(DrydockResourceStatus::STATUS_CLOSED)
+ ->setStatus(DrydockResourceStatus::STATUS_RELEASED)
->save();
// TODO: Hold slot locks until destruction?

File Metadata

Mime Type
text/plain
Expires
Sat, Dec 28, 1:36 PM (6 h, 46 m)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6939067
Default Alt Text
D14153.diff (11 KB)

Event Timeline