Skip to content

Commit

Permalink
New validator and listener API
Browse files Browse the repository at this point in the history
  • Loading branch information
Paul Sandoz committed Oct 26, 2018
1 parent 4796e71 commit f9765b0
Show file tree
Hide file tree
Showing 38 changed files with 3,156 additions and 1,833 deletions.
@@ -1,3 +1,20 @@
/*
*
* Copyright 2018 Netflix, Inc.
*
* Licensed 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 com.netflix.hollow.api.error;

/**
Expand Down
Expand Up @@ -19,6 +19,7 @@

import com.netflix.hollow.api.producer.HollowProducer;
import com.netflix.hollow.api.producer.HollowProducerListener;
import com.netflix.hollow.api.producer.Status;
import com.netflix.hollow.core.read.engine.HollowReadStateEngine;

public class HollowProducerMetrics extends HollowMetrics {
Expand All @@ -38,38 +39,59 @@ public class HollowProducerMetrics extends HollowMetrics {
* @param producerStatus
*/
public void updateCycleMetrics(HollowProducerListener.ProducerStatus producerStatus) {
Status.StatusType st = producerStatus.getStatus() == HollowProducerListener.Status.SUCCESS
? Status.StatusType.SUCCESS
: Status.StatusType.FAIL;

updateCycleMetrics(new Status(st, producerStatus.getCause()), producerStatus.getReadState(), producerStatus.getVersion());
}

/**
* Updates the producer metrics:
* cycles completed, version and type's footprint and ordinals.
* @param status
*/
public void updateCycleMetrics(Status status, HollowProducer.ReadState readState, long version) {
cyclesCompleted++;
if(producerStatus.getStatus() == HollowProducerListener.Status.FAIL) {
if(status.getType() == Status.StatusType.FAIL) {
cycleFailed++;
return;
}
cyclesSucceeded++;

if(producerStatus.getReadState() != null) {
HollowReadStateEngine hollowReadStateEngine = producerStatus.getReadState().getStateEngine();
super.update(hollowReadStateEngine, producerStatus.getVersion());
if(readState != null) {
HollowReadStateEngine hollowReadStateEngine = readState.getStateEngine();
super.update(hollowReadStateEngine, version);
} else {
super.update(producerStatus.getVersion());
super.update(version);
}
}

public void updateBlobTypeMetrics(HollowProducerListener.PublishStatus publishStatus) {
HollowProducer.Blob.Type blobType = publishStatus.getBlob().getType();
Status.StatusType st = publishStatus.getStatus() == HollowProducerListener.Status.SUCCESS
? Status.StatusType.SUCCESS
: Status.StatusType.FAIL;

updateBlobTypeMetrics(new Status(st, publishStatus.getCause()), publishStatus.getBlob());
}

public void updateBlobTypeMetrics(Status status, HollowProducer.Blob blob) {
HollowProducer.Blob.Type blobType = blob.getType();
switch (blobType) {
case SNAPSHOT:
if(publishStatus.getStatus() == HollowProducerListener.Status.SUCCESS)
if(status.getType() == Status.StatusType.SUCCESS)
snapshotsCompleted++;
else
snapshotsFailed++;
break;
case DELTA:
if(publishStatus.getStatus() == HollowProducerListener.Status.SUCCESS)
if(status.getType() == Status.StatusType.SUCCESS)
deltasCompleted++;
else
deltasFailed++;
break;
case REVERSE_DELTA:
if(publishStatus.getStatus() == HollowProducerListener.Status.SUCCESS)
if(status.getType() == Status.StatusType.SUCCESS)
reverseDeltasCompleted++;
else
reverseDeltasFailed++;
Expand Down
Expand Up @@ -26,32 +26,38 @@
* @author Tim Taylor {@literal<tim@toolbear.io>}
*/
public class AbstractHollowProducerListener implements HollowProducerListenerV2 {
// DataModelInitializationListener
@Override public void onProducerInit(long elapsed, TimeUnit unit) {}

// RestoreListener
@Override public void onProducerRestoreStart(long restoreVersion) {}
@Override public void onProducerRestoreComplete(RestoreStatus status, long elapsed, TimeUnit unit) {}
@Override public void onNewDeltaChain(long version) {}

// CycleListener
@Override public void onNewDeltaChain(long version) {}
@Override public void onCycleSkip(CycleSkipReason reason) {}
@Override public void onCycleStart(long version) {}
@Override public void onCycleComplete(ProducerStatus status, long elapsed, TimeUnit unit) {}

@Override public void onNoDeltaAvailable(long version) {}

// PopulateListener
@Override public void onPopulateStart(long version) {}
@Override public void onPopulateComplete(ProducerStatus status, long elapsed, TimeUnit unit) {}

// PublishListener
@Override public void onNoDeltaAvailable(long version) {}
@Override public void onPublishStart(long version) {}
@Override public void onPublishComplete(ProducerStatus status, long elapsed, TimeUnit unit) {}
@Override public void onArtifactPublish(PublishStatus publishStatus, long elapsed, TimeUnit unit) {}
@Override public void onPublishComplete(ProducerStatus status, long elapsed, TimeUnit unit) {}

// IntegrityCheckListener
@Override public void onIntegrityCheckStart(long version) {}
@Override public void onIntegrityCheckComplete(ProducerStatus status, long elapsed, TimeUnit unit) {}

// ValidationListener
@Override public void onValidationStart(long version) {}
@Override public void onValidationComplete(ProducerStatus status, long elapsed, TimeUnit unit) {}

// AnnouncementListener
@Override public void onAnnouncementStart(long version) {}
@Override public void onAnnouncementComplete(ProducerStatus status, long elapsed, TimeUnit unit) {}

}

0 comments on commit f9765b0

Please sign in to comment.