Skip to content

Commit

Permalink
Extract separate DatabaseShardRecorder class
Browse files Browse the repository at this point in the history
  • Loading branch information
electrum committed Mar 22, 2016
1 parent 99abec6 commit 614d183
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 8 deletions.
Expand Up @@ -92,7 +92,7 @@
import static java.util.stream.Collectors.toSet; import static java.util.stream.Collectors.toSet;


public class DatabaseShardManager public class DatabaseShardManager
implements ShardManager, ShardRecorder implements ShardManager
{ {
private static final Logger log = Logger.get(DatabaseShardManager.class); private static final Logger log = Logger.get(DatabaseShardManager.class);


Expand Down Expand Up @@ -504,12 +504,6 @@ private static boolean commitTransaction(ShardDao dao, long transactionId)
return true; return true;
} }


@Override
public void recordCreatedShard(long transactionId, UUID shardUuid)
{
dao.insertCreatedShard(shardUuid, transactionId);
}

@Override @Override
public void createBuckets(long distributionId, int bucketCount) public void createBuckets(long distributionId, int bucketCount)
{ {
Expand Down
@@ -0,0 +1,38 @@
/*
* 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.facebook.presto.raptor.metadata;

import com.facebook.presto.raptor.util.DaoSupplier;

import javax.inject.Inject;

import java.util.UUID;

public class DatabaseShardRecorder
implements ShardRecorder
{
private final ShardDao dao;

@Inject
public DatabaseShardRecorder(DaoSupplier<ShardDao> shardDaoSupplier)
{
this.dao = shardDaoSupplier.onDemand();
}

@Override
public void recordCreatedShard(long transactionId, UUID shardUuid)
{
dao.insertCreatedShard(shardUuid, transactionId);
}
}
Expand Up @@ -15,6 +15,7 @@


import com.facebook.presto.raptor.backup.BackupManager; import com.facebook.presto.raptor.backup.BackupManager;
import com.facebook.presto.raptor.metadata.DatabaseShardManager; import com.facebook.presto.raptor.metadata.DatabaseShardManager;
import com.facebook.presto.raptor.metadata.DatabaseShardRecorder;
import com.facebook.presto.raptor.metadata.MetadataConfig; import com.facebook.presto.raptor.metadata.MetadataConfig;
import com.facebook.presto.raptor.metadata.ShardCleaner; import com.facebook.presto.raptor.metadata.ShardCleaner;
import com.facebook.presto.raptor.metadata.ShardCleanerConfig; import com.facebook.presto.raptor.metadata.ShardCleanerConfig;
Expand Down Expand Up @@ -52,8 +53,9 @@ public void configure(Binder binder)
binder.bind(StorageManager.class).to(OrcStorageManager.class).in(Scopes.SINGLETON); binder.bind(StorageManager.class).to(OrcStorageManager.class).in(Scopes.SINGLETON);
binder.bind(StorageService.class).to(FileStorageService.class).in(Scopes.SINGLETON); binder.bind(StorageService.class).to(FileStorageService.class).in(Scopes.SINGLETON);
binder.bind(ShardManager.class).to(DatabaseShardManager.class).in(Scopes.SINGLETON); binder.bind(ShardManager.class).to(DatabaseShardManager.class).in(Scopes.SINGLETON);
binder.bind(ShardRecorder.class).to(DatabaseShardManager.class).in(Scopes.SINGLETON); binder.bind(ShardRecorder.class).to(DatabaseShardRecorder.class).in(Scopes.SINGLETON);
binder.bind(DatabaseShardManager.class).in(Scopes.SINGLETON); binder.bind(DatabaseShardManager.class).in(Scopes.SINGLETON);
binder.bind(DatabaseShardRecorder.class).in(Scopes.SINGLETON);
binder.bind(ShardRecoveryManager.class).in(Scopes.SINGLETON); binder.bind(ShardRecoveryManager.class).in(Scopes.SINGLETON);
binder.bind(BackupManager.class).in(Scopes.SINGLETON); binder.bind(BackupManager.class).in(Scopes.SINGLETON);
binder.bind(ShardCompactionManager.class).in(Scopes.SINGLETON); binder.bind(ShardCompactionManager.class).in(Scopes.SINGLETON);
Expand Down

0 comments on commit 614d183

Please sign in to comment.