forked from hashgraph/hedera-mirror-node
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
HIP-513 download sidecar files (hashgraph#4106)
- Add SidecarFileReader and its implementation - Add SidecarFile domain class - Add SidecarProperties for sidecar downloading / parsing config - Add SidecarFileRepository - Add sidecar file downloading, verification, and parsing logic to RecordFileDownloader - Extend StreamFilename to parse sidecar record filename - Persist SidecarFile in RecordStreamFileListener.onEnd Signed-off-by: Xin Li <[email protected]>
- Loading branch information
1 parent
2d8c401
commit 44a4bd8
Showing
83 changed files
with
1,184 additions
and
343 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
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
118 changes: 118 additions & 0 deletions
118
...-mirror-common/src/main/java/com/hedera/mirror/common/domain/transaction/SidecarFile.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,118 @@ | ||
package com.hedera.mirror.common.domain.transaction; | ||
|
||
/*- | ||
* | ||
* Hedera Mirror Node | ||
* | ||
* Copyright (C) 2019 - 2022 Hedera Hashgraph, LLC | ||
* | ||
* 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. | ||
* | ||
*/ | ||
|
||
|
||
import com.fasterxml.jackson.annotation.JsonIgnore; | ||
import com.fasterxml.jackson.databind.annotation.JsonSerialize; | ||
import java.io.Serial; | ||
import java.io.Serializable; | ||
import java.util.Collections; | ||
import java.util.List; | ||
import javax.persistence.Column; | ||
import javax.persistence.Entity; | ||
import javax.persistence.Enumerated; | ||
import javax.persistence.IdClass; | ||
import javax.persistence.Transient; | ||
import lombok.AccessLevel; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Data; | ||
import lombok.EqualsAndHashCode; | ||
import lombok.NoArgsConstructor; | ||
import lombok.ToString; | ||
import org.hibernate.annotations.Type; | ||
import org.springframework.data.domain.Persistable; | ||
|
||
import com.hedera.mirror.common.converter.LongListToStringSerializer; | ||
import com.hedera.mirror.common.domain.DigestAlgorithm; | ||
import com.hedera.services.stream.proto.TransactionSidecarRecord; | ||
|
||
@AllArgsConstructor(access = AccessLevel.PRIVATE) | ||
@Builder(toBuilder = true) | ||
@Data | ||
@Entity | ||
@IdClass(SidecarFile.Id.class) | ||
@NoArgsConstructor | ||
public class SidecarFile implements Persistable<SidecarFile.Id> { | ||
|
||
@ToString.Exclude | ||
@Transient | ||
private byte[] actualHash; | ||
|
||
@EqualsAndHashCode.Exclude | ||
@ToString.Exclude | ||
private byte[] bytes; | ||
|
||
@javax.persistence.Id | ||
private long consensusEnd; | ||
|
||
private Integer count; | ||
|
||
@Enumerated | ||
private DigestAlgorithm hashAlgorithm; | ||
|
||
@ToString.Exclude | ||
private byte[] hash; | ||
|
||
@Column(name = "id") | ||
@javax.persistence.Id | ||
private int index; | ||
|
||
private String name; | ||
|
||
@Builder.Default | ||
@ToString.Exclude | ||
@Transient | ||
private List<TransactionSidecarRecord> records = Collections.emptyList(); | ||
|
||
private Integer size; | ||
|
||
@Type(type = "com.vladmihalcea.hibernate.type.array.ListArrayType") | ||
@JsonSerialize(using = LongListToStringSerializer.class) | ||
private List<Integer> types = Collections.emptyList(); | ||
|
||
@JsonIgnore | ||
@Override | ||
public Id getId() { | ||
var id = new Id(); | ||
id.setConsensusEnd(consensusEnd); | ||
id.setIndex(index); | ||
return id; | ||
} | ||
|
||
@JsonIgnore | ||
@Override | ||
public boolean isNew() { | ||
return true; // Since we never update and use a natural ID, avoid Hibernate querying before insert | ||
} | ||
|
||
@Data | ||
public static class Id implements Serializable { | ||
|
||
@Serial | ||
private static final long serialVersionUID = -5844173241500874821L; | ||
|
||
private long consensusEnd; | ||
|
||
private int index; | ||
} | ||
} |
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
Oops, something went wrong.