Skip to content

Commit

Permalink
Merge pull request #337 from kagemomiji/issue336-hikari-pool-problem
Browse files Browse the repository at this point in the history
#336 fix hikari pool problem
  • Loading branch information
kagemomiji authored Jan 24, 2024
2 parents f2e93bf + f1ee6fb commit 712b011
Show file tree
Hide file tree
Showing 48 changed files with 881 additions and 460 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ public String getDefaultLogFile() {
* @return The default database URL. Never {@code null}.
*/
public String getDefaultJDBCUrl() {
return "jdbc:hsqldb:file:" + getAirsonicHome().resolve("db").resolve(getFileSystemAppName()).toString() + ";hsqldb.tx=mvcc;sql.enforce_size=false;sql.char_literal=false;sql.nulls_first=false;sql.pad_space=false;hsqldb.defrag_limit=50;shutdown=true";
return "jdbc:hsqldb:file:" + getAirsonicHome().resolve("db").resolve(getFileSystemAppName()).toString() + ";hsqldb.tx=mvcc;sql.enforce_size=false;sql.char_literal=false;sql.nulls_first=false;sql.pad_space=false;hsqldb.defrag_limit=50;hsqldb.default_table_type=CACHED;shutdown=true";
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ public class AirsonicScanConfig {
// Logger
private static final Logger LOG = LoggerFactory.getLogger(AirsonicHomeConfig.class);

private static final int DEFAULT_SCAN = 10 * 60;
private static final int DEFAULT_FULLSCAN = 60 * 60;
private static final int DEFAULT_SCAN = 60 * 60;
private static final int DEFAULT_FULLSCAN = 4 * 60 * 60;

@Positive
private final Integer fullTimeout;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import java.time.Instant;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import java.util.concurrent.atomic.AtomicInteger;


Expand Down Expand Up @@ -89,7 +90,6 @@ public class Album {
@OneToMany(mappedBy = "album")
private List<StarredAlbum> starredAlbums = new ArrayList<>();

// TODO: add relation to music folder table
@ManyToOne
@JoinColumn(name = "folder_id", referencedColumnName = "id")
private MusicFolder folder;
Expand Down Expand Up @@ -287,4 +287,21 @@ public void setArt(CoverArt art) {
this.art = art;
}

@Override
public int hashCode() {
return Objects.hash(path, folder);
}

@Override
public boolean equals(Object obj) {

if (obj == null || !(obj instanceof Album)) {
return false;
}

Album other = (Album) obj;

return Objects.equals(path, other.path) && Objects.equals(folder, other.folder);
}

}
17 changes: 17 additions & 0 deletions airsonic-main/src/main/java/org/airsonic/player/domain/Artist.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import javax.persistence.*;

import java.time.Instant;
import java.util.Objects;
import java.util.concurrent.atomic.AtomicInteger;


Expand Down Expand Up @@ -127,4 +128,20 @@ public CoverArt getArt() {
public void setArt(CoverArt art) {
this.art = art;
}

@Override
public int hashCode() {
return Objects.hash(name);
}

@Override
public boolean equals(Object obj) {

if (obj == null || !(obj instanceof Artist)) {
return false;
}

Artist other = (Artist) obj;
return Objects.equals(name, other.name);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import javax.persistence.*;

import java.time.Instant;
import java.util.Objects;

/**
* A bookmark within a media file, for a given user.
Expand Down Expand Up @@ -135,4 +136,19 @@ public void setChanged(Instant changed) {
this.changed = changed;
}

@Override
public int hashCode() {
return Objects.hash(id);
}

@Override
public boolean equals(Object obj) {

if (obj == null || !(obj instanceof Bookmark)) {
return false;
}

return Objects.equals(id, ((Bookmark) obj).id);
}

}
17 changes: 17 additions & 0 deletions airsonic-main/src/main/java/org/airsonic/player/domain/Genre.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

import javax.persistence.*;

import java.util.Objects;
import java.util.concurrent.atomic.AtomicInteger;

/**
Expand Down Expand Up @@ -80,4 +81,20 @@ public void incrementAlbumCount() {
public void incrementSongCount() {
songCount.incrementAndGet();
}

@Override
public int hashCode() {
return Objects.hash(name);
}

@Override
public boolean equals(Object obj) {

if (obj == null || !(obj instanceof Genre)) {
return false;
}

Genre other = (Genre) obj;
return Objects.equals(name, other.name);
}
}
16 changes: 16 additions & 0 deletions airsonic-main/src/main/java/org/airsonic/player/domain/Player.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import java.time.Instant;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;

/**
* Represents a remote player. A player has a unique ID, a user-defined name, a
Expand Down Expand Up @@ -421,4 +422,19 @@ public String toString() {
return getDescription();
}

@Override
public int hashCode() {
return Objects.hash(id);
}

@Override
public boolean equals(Object obj) {
if (this == obj) return true;
if (obj == null || !(obj instanceof Player)) {
return false;
}
Player other = (Player) obj;
return Objects.equals(id, other.id);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import java.time.Instant;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;

/**
* @author Sindre Mehus
Expand Down Expand Up @@ -211,4 +212,24 @@ public void setMediaFiles(List<MediaFile> mediaFiles) {
}
}

@Override
public int hashCode() {
return Objects.hash(id);
}

@Override
public boolean equals(Object o) {

if (this == o) {
return true;
}

if (o == null || !(o instanceof Playlist)) {
return false;
}

Playlist p = (Playlist) o;
return Objects.equals(id, p.id);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;

/**
* A Podcast channel. Each channel contain several episodes.
Expand Down Expand Up @@ -153,4 +154,24 @@ public MediaFile getMediaFile() {
return mediaFile;
}

@Override
public int hashCode() {
return Objects.hash(id);
}

@Override
public boolean equals(Object other) {

if (this == other) {
return true;
}

if (other == null || !(other instanceof PodcastChannel)) {
return false;
}

PodcastChannel otherChannel = (PodcastChannel) other;
return Objects.equals(id, otherChannel.id);
}

}
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
package org.airsonic.player.domain;


import javax.persistence.*;

import java.util.Objects;

@Entity
@Table(name = "podcast_channel_rules")
public class PodcastChannelRule {
Expand Down Expand Up @@ -69,4 +70,24 @@ public void setDownloadCount(Integer downloadCount) {
this.downloadCount = downloadCount;
}

@Override
public int hashCode() {
return Objects.hash(id);
}

@Override
public boolean equals(Object other) {

if (this == other) {
return true;
}

if (other == null || !(other instanceof PodcastChannelRule)) {
return false;
}

PodcastChannelRule otherRule = (PodcastChannelRule) other;
return Objects.equals(id, otherRule.id);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import javax.persistence.*;

import java.time.Instant;
import java.util.Objects;

/**
* A Podcast episode belonging to a channel.
Expand Down Expand Up @@ -211,4 +212,20 @@ public void setEpisodeGuid(String episodeGuid) {
this.episodeGuid = episodeGuid;
}

@Override
public int hashCode() {
return Objects.hash(url);
}

@Override
public boolean equals(Object obj) {

if (obj == null || !(obj instanceof PodcastEpisode)) {
return false;
}

PodcastEpisode other = (PodcastEpisode) obj;
return Objects.equals(url, other.url);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

import java.time.Instant;
import java.util.List;
import java.util.Objects;

/**
* Used to save the play queue state for a user.
Expand Down Expand Up @@ -107,4 +108,24 @@ public String getChangedBy() {
public void setChangedBy(String changedBy) {
this.changedBy = changedBy;
}

@Override
public int hashCode() {
return Objects.hash(id);
}

@Override
public boolean equals(Object other) {

if (this == other) {
return true;
}

if (other == null || !(other instanceof SavedPlayQueue)) {
return false;
}

SavedPlayQueue otherQueue = (SavedPlayQueue) other;
return Objects.equals(id, otherQueue.id);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,11 @@
import org.airsonic.player.domain.MusicFolder;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

Expand Down Expand Up @@ -90,9 +94,22 @@ public List<MediaFile> findByAlbumArtistAndAlbumNameAndMediaTypeInAndPresentTrue

public int countByFolderInAndMediaTypeAndPlayCountGreaterThanAndPresentTrue(List<MusicFolder> folders, MediaType mediaType, Integer playCount);

public List<MediaFile> findAll(Specification<MediaFile> spec, Pageable page);

@Transactional
public void deleteAllByPresentFalse();

public List<MediaFile> findByFolderInAndMediaTypeInAndPresentTrue(List<MusicFolder> folders,
Iterable<MediaType> playableTypes, Pageable offsetBasedPageRequest);

@Modifying
@Transactional
@Query("UPDATE MediaFile m SET m.present = true, m.lastScanned = :lastScanned WHERE m.folder = :folder AND m.path IN :paths")
public int markPresent(@Param("folder") MusicFolder folder, @Param("paths") Iterable<String> paths, @Param("lastScanned") Instant lastScanned);

@Modifying
@Transactional
@Query("UPDATE MediaFile m SET m.present = false, m.childrenLastUpdated = :childrenLastUpdated WHERE m.lastScanned < :lastScanned")
public void markNonPresent(@Param("childrenLastUpdated") Instant childrenLastUpdated, @Param("lastScanned") Instant lastScanned);

}
Loading

0 comments on commit 712b011

Please sign in to comment.