• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java DeadlockLoserDataAccessException类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.springframework.dao.DeadlockLoserDataAccessException的典型用法代码示例。如果您正苦于以下问题:Java DeadlockLoserDataAccessException类的具体用法?Java DeadlockLoserDataAccessException怎么用?Java DeadlockLoserDataAccessException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



DeadlockLoserDataAccessException类属于org.springframework.dao包,在下文中一共展示了DeadlockLoserDataAccessException类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: job

import org.springframework.dao.DeadlockLoserDataAccessException; //导入依赖的package包/类
@Bean
public Job job() {
	Step step = stepBuilders.get("step")
	                        .<String, String>chunk(5)
	                        .reader(reader())
	                        .processor(processor())
	                        .writer(writer())
	                        .faultTolerant().retryLimit(3).skipLimit(3)
	                        .retry(OptimisticLockingFailureException.class)
	                        .retry(DeadlockLoserDataAccessException.class)
	                        .skip(DeadlockLoserDataAccessException.class)
	                        .listener(mockRetryListener())
	                        .listener(retryListener())
	                        .build();

	return jobBuilders.get("job").start(step).build();
}
 
开发者ID:debop,项目名称:spring-batch-experiments,代码行数:18,代码来源:RetryBehaviorConfiguration.java


示例2: errorCodeTranslation

import org.springframework.dao.DeadlockLoserDataAccessException; //导入依赖的package包/类
@Test
public void errorCodeTranslation() {
	SQLExceptionTranslator sext = new SQLErrorCodeSQLExceptionTranslator(ERROR_CODES);

	SQLException badSqlEx = new SQLException("", "", 1);
	BadSqlGrammarException bsgex = (BadSqlGrammarException) sext.translate("task", "SQL", badSqlEx);
	assertEquals("SQL", bsgex.getSql());
	assertEquals(badSqlEx, bsgex.getSQLException());

	SQLException invResEx = new SQLException("", "", 4);
	InvalidResultSetAccessException irsex = (InvalidResultSetAccessException) sext.translate("task", "SQL", invResEx);
	assertEquals("SQL", irsex.getSql());
	assertEquals(invResEx, irsex.getSQLException());

	checkTranslation(sext, 5, DataAccessResourceFailureException.class);
	checkTranslation(sext, 6, DataIntegrityViolationException.class);
	checkTranslation(sext, 7, CannotAcquireLockException.class);
	checkTranslation(sext, 8, DeadlockLoserDataAccessException.class);
	checkTranslation(sext, 9, CannotSerializeTransactionException.class);
	checkTranslation(sext, 10, DuplicateKeyException.class);

	SQLException dupKeyEx = new SQLException("", "", 10);
	DataAccessException dksex = sext.translate("task", "SQL", dupKeyEx);
	assertTrue("Not instance of DataIntegrityViolationException",
			DataIntegrityViolationException.class.isAssignableFrom(dksex.getClass()));

	// Test fallback. We assume that no database will ever return this error code,
	// but 07xxx will be bad grammar picked up by the fallback SQLState translator
	SQLException sex = new SQLException("", "07xxx", 666666666);
	BadSqlGrammarException bsgex2 = (BadSqlGrammarException) sext.translate("task", "SQL2", sex);
	assertEquals("SQL2", bsgex2.getSql());
	assertEquals(sex, bsgex2.getSQLException());
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:34,代码来源:SQLErrorCodeSQLExceptionTranslatorTests.java


示例3: testErrorCodeTranslation

import org.springframework.dao.DeadlockLoserDataAccessException; //导入依赖的package包/类
public void testErrorCodeTranslation() {
	SQLExceptionTranslator sext = new SQLErrorCodeSQLExceptionTranslator(ERROR_CODES);

	SQLException badSqlEx = new SQLException("", "", 1);
	BadSqlGrammarException bsgex = (BadSqlGrammarException) sext.translate("task", "SQL", badSqlEx);
	assertEquals("SQL", bsgex.getSql());
	assertEquals(badSqlEx, bsgex.getSQLException());

	SQLException invResEx = new SQLException("", "", 4);
	InvalidResultSetAccessException irsex = (InvalidResultSetAccessException) sext.translate("task", "SQL", invResEx);
	assertEquals("SQL", irsex.getSql());
	assertEquals(invResEx, irsex.getSQLException());

	checkTranslation(sext, 5, DataAccessResourceFailureException.class);
	checkTranslation(sext, 6, DataIntegrityViolationException.class);
	checkTranslation(sext, 7, CannotAcquireLockException.class);
	checkTranslation(sext, 8, DeadlockLoserDataAccessException.class);
	checkTranslation(sext, 9, CannotSerializeTransactionException.class);
	checkTranslation(sext, 10, DuplicateKeyException.class);

	SQLException dupKeyEx = new SQLException("", "", 10);
	DataAccessException dksex = sext.translate("task", "SQL", dupKeyEx);
	assertTrue("Not instance of DataIntegrityViolationException",
			DataIntegrityViolationException.class.isAssignableFrom(dksex.getClass()));

	// Test fallback. We assume that no database will ever return this error code,
	// but 07xxx will be bad grammar picked up by the fallback SQLState translator
	SQLException sex = new SQLException("", "07xxx", 666666666);
	BadSqlGrammarException bsgex2 = (BadSqlGrammarException) sext.translate("task", "SQL2", sex);
	assertEquals("SQL2", bsgex2.getSql());
	assertEquals(sex, bsgex2.getSQLException());
}
 
开发者ID:deathspeeder,项目名称:class-guard,代码行数:33,代码来源:SQLErrorCodeSQLExceptionTranslatorTests.java


示例4: transactionalReader

import org.springframework.dao.DeadlockLoserDataAccessException; //导入依赖的package包/类
@Test
public void transactionalReader() throws Exception {

	while (jmsTemplate.receive() != null) {}

	int read = 12;
	for (int i = 1; i <= read; i++) {
		jmsTemplate.convertAndSend(String.valueOf(i));
	}
	assertThat(productQueueView.getQueueSize()).isEqualTo(read);

	final String toFailWriting = "7";
	doNothing().when(service).writing(argThat(new BaseMatcher<String>() {
		@Override
		public boolean matches(Object input) {
			return !toFailWriting.equals(input);
		}

		@Override
		public void describeTo(Description description) {}
	}));
	doThrow(new DeadlockLoserDataAccessException("", null)).when(service).writing(toFailWriting);

	JobExecution exec = jobLauncher.run(
			transactionalReaderJob,
			new JobParametersBuilder().addLong("time", System.currentTimeMillis()).toJobParameters()
	);
	assertThat(exec.getExitStatus().getExitCode()).isEqualTo(ExitStatus.COMPLETED.getExitCode());

	int expectedWritten = 5;
	int stillOnQueue = (int) productQueueView.getQueueSize();
	assertRead(10, exec);
	assertThat(stillOnQueue).isEqualTo(read - expectedWritten);
	assertWrite(expectedWritten, exec);
}
 
开发者ID:debop,项目名称:spring-batch-experiments,代码行数:36,代码来源:TransactionBehaviorTest.java


示例5: transactionalReaderJob

import org.springframework.dao.DeadlockLoserDataAccessException; //导入依赖的package包/类
@Bean
public Job transactionalReaderJob() {
	// Tx를 위해 reader 정보를 Queue에 넣습니다.
	Step step = stepBuilders.get("transactionalReaderStep")
	                        .<String, String>chunk(5)
	                        .readerIsTransactionalQueue()
	                        .faultTolerant().skipLimit(5).skip(DeadlockLoserDataAccessException.class)
	                        .reader(jmsReader())
	                        .processor(processor())
	                        .writer(writer())
	                        .build();

	return jobBuilders.get("transactionalReaderJob").start(step).build();
}
 
开发者ID:debop,项目名称:spring-batch-experiments,代码行数:15,代码来源:TransactionBehaviorConfiguration.java


示例6: exceptionInWritingSkippable

import org.springframework.dao.DeadlockLoserDataAccessException; //导入依赖的package包/类
@Test
public void exceptionInWritingSkippable() throws Exception {
	int read = 12;
	configureServiceForRead(service, read);

	final String toFailWriting = "7";
	doNothing().when(service).writing(argThat(new BaseMatcher<String>() {
		@Override
		public boolean matches(Object input) {
			return !toFailWriting.equals(input);
		}

		@Override
		public void describeTo(Description desc) { }
	}));

	doThrow(new DeadlockLoserDataAccessException("", null)).when(service).writing(toFailWriting);

	JobExecution exec = jobLauncher.run(
			job,
			new JobParametersBuilder().addLong("time", System.currentTimeMillis()).toJobParameters()
	);

	assertThat(exec.getExitStatus().getExitCode()).isEqualToIgnoringCase(ExitStatus.COMPLETED.getExitCode());
	verify(service, times(5 + 5 + 2 + 1)).reading();
	// verify(service, times(5 + 5 + (1 + 1) + 5 + 2)).processing(anyString());
	verify(service, times(5 + 5 + 5 + 5 + 5 + 2)).processing(anyString());
	verify(service, times(5 + 2 + 2 + 2 + 5 + 2)).writing(anyString());
	assertRead(read, exec);
	assertWrite(read - 1, exec);
	assertReadSkip(0, exec);
	assertProcessSkip(0, exec);
	assertWriteSkip(1, exec);
	assertCommit(1 + 4 + 1, exec);
	assertRollback(3 + 1, exec);
}
 
开发者ID:debop,项目名称:spring-batch-experiments,代码行数:37,代码来源:RetryBehaviorTest.java


示例7: exceptionInProcessingSkippable

import org.springframework.dao.DeadlockLoserDataAccessException; //导入依赖的package包/类
@Test
public void exceptionInProcessingSkippable() throws Exception {
	int read = 12;
	configureServiceForRead(service, read);

	final String toFailProcessing = "7";
	doNothing().when(service).processing(argThat(new BaseMatcher<String>() {
		@Override
		public boolean matches(Object input) {
			return !toFailProcessing.equals(input);
		}

		@Override
		public void describeTo(Description desc) { }

	}));
	doThrow(new DeadlockLoserDataAccessException("", null)).when(service).processing(toFailProcessing);

	doNothing().when(service).writing(anyString());

	JobExecution exec = jobLauncher.run(
			job,
			new JobParametersBuilder().addLong("time", System.currentTimeMillis()).toJobParameters()
	);

	assertThat(exec.getExitStatus().getExitCode()).isEqualToIgnoringCase(ExitStatus.COMPLETED.getExitCode());
	verify(service, times(5 + 5 + 2 + 1)).reading();
	verify(service, times(5 + 2 + 2 + 2 + 4 + 2)).processing(anyString());
	verify(service, times(5 + 4 + 2)).writing(anyString());
	assertRead(read, exec);
	assertWrite(read - 1, exec);
	assertReadSkip(0, exec);
	assertProcessSkip(1, exec);
	assertWriteSkip(0, exec);
	assertCommit(3, exec);
	assertRollback(3, exec); // rollback on each retry
}
 
开发者ID:debop,项目名称:spring-batch-experiments,代码行数:38,代码来源:RetryBehaviorTest.java


示例8: exceptionInWritingNotExhausted

import org.springframework.dao.DeadlockLoserDataAccessException; //导入依赖的package包/类
@Test
public void exceptionInWritingNotExhausted() throws Exception {
	int read = 12;
	configureServiceForRead(service, read);

	final String toFailWriting = "7";
	doNothing().when(service).writing(argThat(new BaseMatcher<String>() {
		@Override
		public boolean matches(Object input) {
			return !toFailWriting.equals(input);
		}

		@Override
		public void describeTo(Description desc) { }

	}));

	doThrow(new DeadlockLoserDataAccessException("", null))
			.doThrow(new DeadlockLoserDataAccessException("", null))
			.doNothing()
			.when(service).writing(toFailWriting);


	JobExecution exec = jobLauncher.run(
			job,
			new JobParametersBuilder().addLong("time", System.currentTimeMillis()).toJobParameters()
	);

	assertThat(exec.getExitStatus().getExitCode()).isEqualToIgnoringCase(ExitStatus.COMPLETED.getExitCode());
	verify(service, times(5 + 5 + 2 + 1)).reading();
	verify(service, times(5 + 5 + 5 + 5 + 2)).processing(anyString());
	verify(service, times(5 + 2 + 2 + 5 + 2)).writing(anyString());
	verify(mockRetryListener, times(2)).onError(any(RetryContext.class), any(RetryCallback.class), any(Throwable.class));
	assertRead(read, exec);
	assertWrite(read, exec);
	assertReadSkip(0, exec);
	assertProcessSkip(0, exec);
	assertWriteSkip(0, exec);
	assertCommit(3, exec);
	assertRollback(2, exec);
}
 
开发者ID:debop,项目名称:spring-batch-experiments,代码行数:42,代码来源:RetryBehaviorTest.java


示例9: retryPolicy

import org.springframework.dao.DeadlockLoserDataAccessException; //导入依赖的package包/类
@Test
public void retryPolicy() throws Exception {
	int read = 12;
	configureServiceForRead(service, read);

	final String toFailProcessingConcurrency = "7";
	final String toFailProcessingDeadlock = "11";
	final int maxAttemptsConcurrency = 2;
	final int maxAttemptsDeadlock = 4;
	doAnswer(new Answer<Void>() {

		private int countConcurrency = 0;
		private int countDeadlock = 0;

		@Override
		public Void answer(InvocationOnMock invocation) throws Throwable {
			String item = (String) invocation.getArguments()[0];
			if (toFailProcessingConcurrency.equals(item) &&
					countConcurrency < maxAttemptsConcurrency
					) {
				countConcurrency++;
				throw new ConcurrencyFailureException("");
			} else if (toFailProcessingDeadlock.equals(item) &&
					countDeadlock < maxAttemptsDeadlock
					) {
				countDeadlock++;
				throw new DeadlockLoserDataAccessException("", null);
			}
			return null;
		}
	}).when(service).writing(anyString());

	JobExecution exec = jobLauncher.run(
			retryPolicyJob,
			new JobParametersBuilder().addLong("time", System.currentTimeMillis()).toJobParameters()
	);

	assertThat(exec.getExitStatus().getExitCode()).isEqualToIgnoringCase(ExitStatus.COMPLETED.getExitCode());
	assertRead(read, exec);
	assertWrite(read, exec);
}
 
开发者ID:debop,项目名称:spring-batch-experiments,代码行数:42,代码来源:RetryBehaviorTest.java



注:本文中的org.springframework.dao.DeadlockLoserDataAccessException类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java ContainersMonitor类代码示例发布时间:2022-05-22
下一篇:
Java BlockEntityFlowerPot类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap