-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #286 from rpmoore/null_node_id
Minor refactoring for JobPartTracker. Added a workaround for a NPE t…
- Loading branch information
Showing
7 changed files
with
143 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,7 +15,7 @@ | |
|
||
allprojects { | ||
group = 'com.spectralogic.ds3' | ||
version = '3.0.3' | ||
version = '3.0.4' | ||
} | ||
|
||
subprojects { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
61 changes: 61 additions & 0 deletions
61
ds3-sdk/src/main/java/com/spectralogic/ds3client/helpers/JobPartTrackerImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
/* | ||
* ****************************************************************************** | ||
* Copyright 2014-2016 Spectra Logic Corporation. All Rights Reserved. | ||
* Licensed under the Apache License, Version 2.0 (the "License"). You may not use | ||
* this file except in compliance with the License. A copy of the License is located at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* or in the "license" file accompanying this file. | ||
* This file 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 com.spectralogic.ds3client.helpers; | ||
|
||
import java.util.Map; | ||
|
||
public class JobPartTrackerImpl implements JobPartTracker { | ||
|
||
private final Map<String, ObjectPartTracker> trackers; | ||
|
||
public JobPartTrackerImpl(final Map<String, ObjectPartTracker> trackers) { | ||
this.trackers = trackers; | ||
} | ||
|
||
public void completePart(final String key, final ObjectPart objectPart) { | ||
trackers.get(key).completePart(objectPart); | ||
} | ||
|
||
public boolean containsPart(final String key, final ObjectPart objectPart) { | ||
return trackers.get(key).containsPart(objectPart); | ||
} | ||
|
||
public JobPartTracker attachDataTransferredListener(final DataTransferredListener listener) { | ||
for (final ObjectPartTracker tracker : this.trackers.values()) { | ||
tracker.attachDataTransferredListener(listener); | ||
} | ||
return this; | ||
} | ||
|
||
public JobPartTracker attachObjectCompletedListener(final ObjectCompletedListener listener) { | ||
for (final ObjectPartTracker tracker : this.trackers.values()) { | ||
tracker.attachObjectCompletedListener(listener); | ||
} | ||
return this; | ||
} | ||
|
||
public void removeDataTransferredListener(final DataTransferredListener listener) { | ||
for (final ObjectPartTracker tracker : this.trackers.values()) { | ||
tracker.removeDataTransferredListener(listener); | ||
} | ||
} | ||
|
||
public void removeObjectCompletedListener(final ObjectCompletedListener listener) { | ||
for (final ObjectPartTracker tracker : this.trackers.values()) { | ||
tracker.removeObjectCompletedListener(listener); | ||
} | ||
} | ||
} |
52 changes: 52 additions & 0 deletions
52
ds3-sdk/src/test/java/com/spectralogic/ds3client/helpers/ChunkTransferrer_Test.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
/* | ||
* ****************************************************************************** | ||
* Copyright 2014-2016 Spectra Logic Corporation. All Rights Reserved. | ||
* Licensed under the Apache License, Version 2.0 (the "License"). You may not use | ||
* this file except in compliance with the License. A copy of the License is located at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* or in the "license" file accompanying this file. | ||
* This file 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 com.spectralogic.ds3client.helpers; | ||
|
||
import com.google.common.collect.ImmutableList; | ||
import com.spectralogic.ds3client.Ds3Client; | ||
import com.spectralogic.ds3client.models.JobNode; | ||
import com.spectralogic.ds3client.models.Objects; | ||
import com.spectralogic.ds3client.serializer.XmlProcessingException; | ||
import org.junit.Test; | ||
|
||
import java.io.IOException; | ||
import java.security.SignatureException; | ||
import java.util.ArrayList; | ||
import java.util.UUID; | ||
|
||
import static org.mockito.Matchers.any; | ||
import static org.mockito.Mockito.mock; | ||
import static org.mockito.Mockito.times; | ||
import static org.mockito.Mockito.verify; | ||
|
||
public class ChunkTransferrer_Test { | ||
|
||
@Test | ||
public void nullJobNode() throws XmlProcessingException, SignatureException, IOException { | ||
final Ds3Client client = mock(Ds3Client.class); | ||
|
||
final ChunkTransferrer chunkTransferrer = new ChunkTransferrer(null, client, null, 1); | ||
final ImmutableList.Builder<Objects> objectsBuilder = ImmutableList.builder(); | ||
|
||
final Objects objects = new Objects(); | ||
objects.setChunkId(UUID.randomUUID()); | ||
objects.setChunkNumber(0); | ||
objectsBuilder.add(objects); | ||
|
||
chunkTransferrer.transferChunks(new ArrayList<JobNode>(), objectsBuilder.build()); | ||
|
||
verify(client, times(0)).newForNode((JobNode) any()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters