Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IGNITE-5702 #2246

Closed
wants to merge 17 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -156,6 +156,41 @@ public class JdbcPreparedStatementSelfTest extends GridCommonAbstractTest {
}
}

/**
* @throws Exception If failed.
*/
public void testRepeatableUsage() throws Exception {
stmt = conn.prepareStatement("select * from TestObject where id = ?");

stmt.setInt(1, 1);

ResultSet rs = stmt.executeQuery();

int cnt = 0;

while (rs.next()) {
if (cnt == 0)
assertEquals(1, rs.getInt(1));

cnt++;
}

assertEquals(1, cnt);

cnt = 0;

rs = stmt.executeQuery();

while (rs.next()) {
if (cnt == 0)
assertEquals(1, rs.getInt(1));

cnt++;
}

assertEquals(1, cnt);
}

/**
* @throws Exception If failed.
*/
Expand Down
Expand Up @@ -153,6 +153,41 @@ public class JdbcPreparedStatementSelfTest extends GridCommonAbstractTest {
}
}

/**
* @throws Exception If failed.
*/
public void testRepeatableUsage() throws Exception {
stmt = conn.prepareStatement("select * from TestObject where id = ?");

stmt.setInt(1, 1);

ResultSet rs = stmt.executeQuery();

int cnt = 0;

while (rs.next()) {
if (cnt == 0)
assertEquals(1, rs.getInt(1));

cnt++;
}

assertEquals(1, cnt);

cnt = 0;

rs = stmt.executeQuery();

while (rs.next()) {
if (cnt == 0)
assertEquals(1, rs.getInt(1));

cnt++;
}

assertEquals(1, cnt);
}

/**
* @throws Exception If failed.
*/
Expand Down
Expand Up @@ -161,6 +161,41 @@ public class JdbcThinPreparedStatementSelfTest extends JdbcThinAbstractSelfTest
}
}

/**
* @throws Exception If failed.
*/
public void testRepeatableUsage() throws Exception {
stmt = conn.prepareStatement(SQL_PART + " where id = ?");

stmt.setInt(1, 1);

ResultSet rs = stmt.executeQuery();

int cnt = 0;

while (rs.next()) {
if (cnt == 0)
assertEquals(1, rs.getInt(1));

cnt++;
}

assertEquals(1, cnt);

cnt = 0;

rs = stmt.executeQuery();

while (rs.next()) {
if (cnt == 0)
assertEquals(1, rs.getInt(1));

cnt++;
}

assertEquals(1, cnt);
}

/**
* @throws Exception If failed.
*/
Expand Down
Expand Up @@ -55,7 +55,7 @@ public class PersistentStoreConfiguration implements Serializable {
/** */
public static final int DFLT_WAL_SEGMENTS = 10;

/** */
/** Default WAL file segment size, 64MBytes */
public static final int DFLT_WAL_SEGMENT_SIZE = 64 * 1024 * 1024;

/** Default wal mode. */
Expand Down Expand Up @@ -103,10 +103,10 @@ public class PersistentStoreConfiguration implements Serializable {
/** Number of work WAL segments. */
private int walSegments = DFLT_WAL_SEGMENTS;

/** Number of WAL segments to keep. */
/** Size of one WAL segment in bytes. 64 Mb is used by default. Maximum value is 2Gb */
private int walSegmentSize = DFLT_WAL_SEGMENT_SIZE;

/** WAL persistence path. */
/** Directory where WAL is stored (work directory) */
private String walStorePath = DFLT_WAL_STORE_PATH;

/** WAL archive path. */
Expand All @@ -121,7 +121,7 @@ public class PersistentStoreConfiguration implements Serializable {
/** WAl thread local buffer size. */
private int tlbSize = DFLT_TLB_SIZE;

/** Wal flush frequency. */
/** Wal flush frequency in milliseconds. */
private int walFlushFreq = DFLT_WAL_FLUSH_FREQ;

/** Wal fsync delay. */
Expand All @@ -146,6 +146,11 @@ public class PersistentStoreConfiguration implements Serializable {
/** Time interval (in milliseconds) for rate-based metrics. */
private long rateTimeInterval = DFLT_RATE_TIME_INTERVAL_MILLIS;

/**
* Time interval (in milliseconds) for running auto archiving for incompletely WAL segment
*/
private long walAutoArchiveAfterInactivity = -1;

/**
* Returns a path the root directory where the Persistent Store will persist data and indexes.
*/
Expand Down Expand Up @@ -297,7 +302,7 @@ public PersistentStoreConfiguration setWalSegments(int walSegments) {
}

/**
* Gets size of a WAL segment.
* Gets size of a WAL segment in bytes.
*
* @return WAL segment size.
*/
Expand All @@ -308,7 +313,7 @@ public int getWalSegmentSize() {
/**
* Sets size of a WAL segment.
*
* @param walSegmentSize WAL segment size. 64 MB is used by default.
* @param walSegmentSize WAL segment size. 64 MB is used by default. Maximum value is 2Gb
* @return {@code this} for chaining.
*/
public PersistentStoreConfiguration setWalSegmentSize(int walSegmentSize) {
Expand Down Expand Up @@ -533,6 +538,28 @@ public PersistentStoreConfiguration setAlwaysWriteFullPages(boolean alwaysWriteF
return this;
}

/**
* <b>Note:</b> setting this value with {@link WALMode#DEFAULT} may generate file size overhead for WAL segments in case
* grid is used rarely.
*
* @param walAutoArchiveAfterInactivity time in millis to run auto archiving segment (even if incomplete) after last
* record logging. <br> Positive value enables incomplete segment archiving after timeout (inactivity). <br> Zero or
* negative value disables auto archiving.
* @return current configuration instance for chaining
*/
public PersistentStoreConfiguration setWalAutoArchiveAfterInactivity(long walAutoArchiveAfterInactivity) {
this.walAutoArchiveAfterInactivity = walAutoArchiveAfterInactivity;

return this;
}

/**
* @return time in millis to run auto archiving WAL segment (even if incomplete) after last record log
*/
public long getWalAutoArchiveAfterInactivity() {
return walAutoArchiveAfterInactivity;
}

/** {@inheritDoc} */
@Override public String toString() {
return S.toString(PersistentStoreConfiguration.class, this);
Expand Down
12 changes: 12 additions & 0 deletions modules/core/src/main/java/org/apache/ignite/events/EventType.java
Expand Up @@ -766,6 +766,18 @@ public interface EventType {
*/
public static final int EVT_IGFS_FILE_PURGED = 127;

/**
* Built-in event type: WAL segment movement to archive folder completed
* <p>
* Fired for each completed WAL segment which was moved to archive
* <p>
* NOTE: all types in range <b>from 1 to 1000 are reserved</b> for
* internal Ignite events and should not be used by user-defined events.
*
* @see WalSegmentArchivedEvent
*/
public static final int EVT_WAL_SEGMENT_ARCHIVED = 128;

/**
* All checkpoint events. This array can be directly passed into
* {@link IgniteEvents#localListen(IgnitePredicate, int...)} method to
Expand Down
@@ -0,0 +1,62 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You 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 org.apache.ignite.events;

import java.io.File;
import org.apache.ignite.cluster.ClusterNode;
import org.jetbrains.annotations.NotNull;

/**
* Event indicates there was movement of WAL segment file to archive has been completed
*/
public class WalSegmentArchivedEvent extends EventAdapter {
/** */
private static final long serialVersionUID = 0L;

/** Absolute WAL segment file index. */
private long absWalSegmentIdx;

/** Destination archive file. This file is completed and closed archive segment */
private final File archiveFile;

/**
* Creates WAL segment event
*
* @param node Node.
* @param absWalSegmentIdx Absolute wal segment index.
* @param archiveFile Archive file.
*/
public WalSegmentArchivedEvent(
@NotNull final ClusterNode node,
final long absWalSegmentIdx,
final File archiveFile) {
super(node, "", EventType.EVT_WAL_SEGMENT_ARCHIVED);
this.absWalSegmentIdx = absWalSegmentIdx;
this.archiveFile = archiveFile;
}

/** @return {@link #archiveFile} */
public File getArchiveFile() {
return archiveFile;
}

/** @return {@link #absWalSegmentIdx} */
public long getAbsWalSegmentIdx() {
return absWalSegmentIdx;
}
}
Expand Up @@ -84,9 +84,11 @@ enum DiscoveryDataExchangeType {
* Callback that notifies that kernal has successfully started,
* including all managers and processors.
*
* @param active Cluster active flag (note: should be used carefully since state can
* change concurrently).
* @throws IgniteCheckedException Thrown in case of any errors.
*/
public void onKernalStart() throws IgniteCheckedException;
public void onKernalStart(boolean active) throws IgniteCheckedException;

/**
* Callback to notify that kernal is about to stop.
Expand Down
Expand Up @@ -61,7 +61,7 @@ public PluginProvider plugin() {
}

/** {@inheritDoc} */
@Override public void onKernalStart() throws IgniteCheckedException {
@Override public void onKernalStart(boolean active) throws IgniteCheckedException {
plugin.onIgniteStart();
}

Expand Down