Skip to content
This repository has been archived by the owner on May 18, 2021. It is now read-only.

Commit

Permalink
Reformat code with airlift code style.
Browse files Browse the repository at this point in the history
Load the code into IntelliJ, get the airlift code style and run Ctrl+Alt+L in the root folder.
  • Loading branch information
Henning Schmiedehausen committed Jun 26, 2014
1 parent 063a676 commit aa2f7de
Show file tree
Hide file tree
Showing 125 changed files with 543 additions and 460 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ public DeploymentRepresentation(
this.assignment = assignment;
if (resources == null) {
this.resources = ImmutableMap.of();
} else {
}
else {
this.resources = ImmutableMap.copyOf(resources);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@
import static io.airlift.airship.shared.SlotLifecycleState.UNKNOWN;
import static io.airlift.airship.shared.SlotStatus.createSlotStatus;

public class DeploymentSlot implements Slot
public class DeploymentSlot
implements Slot
{
private static final Logger log = Logger.get(DeploymentSlot.class);

Expand Down Expand Up @@ -208,7 +209,8 @@ public SlotStatus assign(Installation installation)
SlotLifecycleState state;
if (shouldStart) {
state = lifecycleManager.start(deployment);
} else {
}
else {
state = STOPPED;
}

Expand Down Expand Up @@ -402,7 +404,6 @@ private void lock()
}
}


private void unlock()
{
lockOwner = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@
import static io.airlift.airship.shared.FileUtils.listFiles;
import static io.airlift.json.JsonCodec.jsonCodec;

public class DirectoryDeploymentManager implements DeploymentManager
public class DirectoryDeploymentManager
implements DeploymentManager
{
private static final Logger log = Logger.get(DirectoryDeploymentManager.class);
private final JsonCodec<DeploymentRepresentation> jsonCodec = jsonCodec(DeploymentRepresentation.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@

import static io.airlift.airship.shared.FileUtils.listFiles;

public class DirectoryDeploymentManagerFactory implements DeploymentManagerFactory
public class DirectoryDeploymentManagerFactory
implements DeploymentManagerFactory
{
private final String location;
private final Duration tarTimeout;
Expand Down Expand Up @@ -102,13 +103,14 @@ private String toBaseName(Installation installation)
String baseName;
if (mavenCoordinates != null) {
baseName = mavenCoordinates.getArtifactId();
} else if (configSpec.startsWith("@")) {
}
else if (configSpec.startsWith("@")) {

baseName = configSpec.substring(1);
} else {
}
else {
baseName = configSpec;
}
return baseName;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@
import static io.airlift.airship.shared.SlotLifecycleState.STOPPED;
import static io.airlift.airship.shared.SlotLifecycleState.UNKNOWN;

public class LauncherLifecycleManager implements LifecycleManager
public class LauncherLifecycleManager
implements LifecycleManager
{
private static final Logger log = Logger.get(LauncherLifecycleManager.class);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@

import java.util.List;

public class LockTimeoutException extends RuntimeException
public class LockTimeoutException
extends RuntimeException
{
public LockTimeoutException(Thread ownerThread, Duration lockWait, List<StackTraceElement> acquisitionLocation)
{
Expand All @@ -14,5 +15,4 @@ public LockTimeoutException(Thread ownerThread, Duration lockWait, List<StackTra
ownerThread,
acquisitionLocation == null ? null : Joiner.on("\n at ").join(acquisitionLocation)));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -63,5 +63,4 @@ public Response setServiceInventory(ServiceDescriptorsRepresentation descriptor)
this.descriptor.set(descriptor);
return Response.ok().build();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,6 @@ public Response getAllSlotsStatus(@Context UriInfo uriInfo)
.build();
}


private static URI getSelfUri(UUID slotId, URI baseUri)
{
return uriBuilderFrom(baseUri).appendPath("/v1/agent/slot/").appendPath(slotId.toString()).build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ public void testStateMachine()
// stopped.kill => stopped
assertEquals(manager.kill(appleDeployment), STOPPED);
assertEquals(manager.status(appleDeployment), STOPPED);

}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
import java.io.File;
import java.util.UUID;

public class MockDeploymentManager implements DeploymentManager
public class MockDeploymentManager
implements DeploymentManager
{
private final String location;
private final UUID slotId = UUID.randomUUID();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@

import java.util.List;

public class MockDeploymentManagerFactory implements DeploymentManagerFactory
public class MockDeploymentManagerFactory
implements DeploymentManagerFactory
{
@Override
public List<DeploymentManager> loadSlots()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@

import static com.google.common.collect.Maps.newHashMap;

public class MockLifecycleManager implements LifecycleManager
public class MockLifecycleManager
implements LifecycleManager
{
private final Map<UUID, SlotLifecycleState> states = newHashMap();
private final Set<UUID> nodeConfigUpdated = Sets.newHashSet();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ private ResourcesUtil()
{
}

public static Map<String,Integer> TEST_RESOURCES = ImmutableMap.<String,Integer>builder()
public static Map<String, Integer> TEST_RESOURCES = ImmutableMap.<String, Integer>builder()
.put("cpu", 8)
.put("memory", 1024)
.build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public void setup()
.setSlotsDir(new File(tempDir, "slots").getAbsolutePath())
.setResourcesFile(resourcesFile.getAbsolutePath());

nodeInfo = new NodeInfo("test", "pool", "nodeId", InetAddress.getByAddress(new byte[]{127, 0, 0, 1}), null, null, "location", "binarySpec", "configSpec");
nodeInfo = new NodeInfo("test", "pool", "nodeId", InetAddress.getByAddress(new byte[] {127, 0, 0, 1}), null, null, "location", "binarySpec", "configSpec");

agent = new Agent(
config,
Expand All @@ -48,5 +48,4 @@ public void test()
assertEquals(agent.getLocation(), agent.getLocation());
assertEquals(agent.getResources(), TEST_RESOURCES);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@ public class TestAgentConfig
public void testDefaults()
{
ConfigAssertions.assertRecordedDefaults(ConfigAssertions.recordDefaults(AgentConfig.class)
.setSlotsDir("slots")
.setResourcesFile("etc/resources.properties")
.setLauncherTimeout(new Duration(5, TimeUnit.SECONDS))
.setLauncherStopTimeout(new Duration(15, TimeUnit.SECONDS))
.setTarTimeout(new Duration(1, TimeUnit.MINUTES))
.setMaxLockWait(new Duration(1, TimeUnit.SECONDS))
.setSlotsDir("slots")
.setResourcesFile("etc/resources.properties")
.setLauncherTimeout(new Duration(5, TimeUnit.SECONDS))
.setLauncherStopTimeout(new Duration(15, TimeUnit.SECONDS))
.setTarTimeout(new Duration(1, TimeUnit.MINUTES))
.setMaxLockWait(new Duration(1, TimeUnit.SECONDS))
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,5 +54,4 @@ public void testGetAllSlotsStatus()
assertEquals(actual.getResources(), TEST_RESOURCES);
assertEquals(actual.getLocation(), agent.getLocation());
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@
import static io.airlift.airship.shared.FileUtils.deleteRecursively;
import static org.testng.Assert.assertEquals;

public class TestDirectoryDeploymentManager extends AbstractDeploymentManagerTest
public class TestDirectoryDeploymentManager
extends AbstractDeploymentManagerTest
{
private File tempDir;
private InstallationHelper installationHelper;
Expand All @@ -50,7 +51,6 @@ public void tearDown()
if (installationHelper != null) {
installationHelper.destroy();
}

}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertTrue;

public class TestLauncherLifecycleManager extends AbstractLifecycleManagerTest
public class TestLauncherLifecycleManager
extends AbstractLifecycleManagerTest
{
private File tempDir;
private File slotDir;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
import io.airlift.airship.shared.InstallationHelper;
import org.testng.annotations.BeforeMethod;

public class TestMockDeploymentManager extends AbstractDeploymentManagerTest
public class TestMockDeploymentManager
extends AbstractDeploymentManagerTest
{
@BeforeMethod
protected void setUp()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@
import static io.airlift.airship.shared.AssignmentHelper.APPLE_ASSIGNMENT;
import static io.airlift.airship.shared.AssignmentHelper.BANANA_ASSIGNMENT;

public class TestMockLifecycleManager extends AbstractLifecycleManagerTest
public class TestMockLifecycleManager
extends AbstractLifecycleManagerTest
{
@BeforeMethod
protected void setUp()
Expand All @@ -35,7 +36,7 @@ protected void setUp()
new File("apple"),
new File("apple-data"),
APPLE_ASSIGNMENT,
ImmutableMap.<String, Integer>of( "memory", 512));
ImmutableMap.<String, Integer>of("memory", 512));
bananaDeployment = new Deployment(
UUID.randomUUID(),
"location/banana",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,6 @@ public class TestServer
private Installation bananaInstallation;
private File tempDir;


@BeforeClass
public void startServer()
throws Exception
Expand Down Expand Up @@ -263,7 +262,6 @@ public void testInstallSlot()
assertEquals(response.getValue(), expected);
}


@Test
public void testTerminateSlot()
throws Exception
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,5 @@ public void testLifecycle()
// stopped.kill => stopped
assertEquals(slot.kill(), stopped);
assertEquals(slot.status(), stopped);

}
}
4 changes: 2 additions & 2 deletions airship-agent/src/test/resources/deployment.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"deploymentId":"deployment1",
"nodeId" : "12345678-1234-1234-1234-123456789012",
"deploymentId": "deployment1",
"nodeId": "12345678-1234-1234-1234-123456789012",
"assignment": {
"binary": "food.fruit:apple:1.0",
"config": "@prod:apple:1.0"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@

import static io.airlift.airship.cli.Ansi.colorize;

public class AgentRecord implements Record
public class AgentRecord
implements Record
{
public static List<Record> toAgentRecords(Iterable<AgentStatusRepresentation> agents)
{
Expand Down Expand Up @@ -85,12 +86,15 @@ public String getColorizedValue(Column column)
AgentLifecycleState state = AgentLifecycleState.valueOf(toString(value));
if (AgentLifecycleState.ONLINE == state) {
return colorize(state, Color.GREEN);
} else if (AgentLifecycleState.OFFLINE == state) {
}
else if (AgentLifecycleState.OFFLINE == state) {
return colorize(state, Color.RED);
} else if (AgentLifecycleState.PROVISIONING == state) {
}
else if (AgentLifecycleState.PROVISIONING == state) {
return colorize(state, Color.BLUE);
}
} else if (Column.statusMessage == column) {
}
else if (Column.statusMessage == column) {
return colorize(value, Color.RED);
}
return toString(value);
Expand Down
Loading

0 comments on commit aa2f7de

Please sign in to comment.