Datanode其中一个磁盘卷故障(Datanode one of the disk volume failure)
我的hadoop集群datanode中的一个磁盘已变为只读。 我不确定是什么原因引起了这个问题。 从datanode中删除此卷会导致数据丢失吗? 如果我要面对数据丢失,如何处理这个?
One of the disk from my hadoop cluster datanode has become read only. I am not sure what caused this problem. Will removing this volume from the datanode cause data lose ?? How to handle this if i am going to face data lose?
原文:https://stackoverflow.com/questions/36307680
最满意答案
我发现要做到这一点的最佳方式是:
- 开始测试
- 开始交易
- (可选)使用类似DBUnit的方式加载测试需要的任何DB数据
- 运行测试
- 回滚事务
请注意,所有数据库操作都发生在同一个事务中。 由于此事务在测试结束时回滚(即使引发异常),数据库在测试结束时应始终处于与开始时相同的状态。
Spring提供了一些真正有用的类,它们将负责为每个测试启动和回滚事务。 如果您使用的是Spring&JUnit4,并且不介意您的测试类需要扩展Spring类,那么最简单的选择可能是扩展
AbstractTransactionalJUnit4SpringContextTests
// Location of the Spring config file(s) @ContextConfiguration(locations = {"/application-context-test.xml", "classpath*:/application-context-persistence-test.xml"}) // Transaction manager bean name @TransactionConfiguration(transactionManager = "hsqlTransactionManager", defaultRollback = true) @Transactional(propagation=Propagation.REQUIRES_NEW) public class MyTransactionalTests extends AbstractTransactionalJUnit4SpringContextTests { @Test public void thisWillRunInATransactionThatIsAutomaticallyRolledBack() {} }
如果您不想扩展Spring类,则可以使用注释来配置测试运行器。 Spring还支持许多其他主要的单元测试框架和旧版本的JUnit。
The best way I've found to do this is:
- start test
- start transaction
- (optional) load any DB data the test requires using something like DBUnit
- run test
- rollback transaction
Notice that all DB operations occur within the same transaction. Because this transaction is rolled back at the end of the test (even if an exception is thrown), the database should always be in the same state at the end of the test as it was at the start.
Spring provides some really useful classes that will take care of starting and rolling back the transaction for each test. If you're using Spring & JUnit4 and don't mind that your test classes have to extend a Spring class the easiest option is probably to extend
AbstractTransactionalJUnit4SpringContextTests
// Location of the Spring config file(s) @ContextConfiguration(locations = {"/application-context-test.xml", "classpath*:/application-context-persistence-test.xml"}) // Transaction manager bean name @TransactionConfiguration(transactionManager = "hsqlTransactionManager", defaultRollback = true) @Transactional(propagation=Propagation.REQUIRES_NEW) public class MyTransactionalTests extends AbstractTransactionalJUnit4SpringContextTests { @Test public void thisWillRunInATransactionThatIsAutomaticallyRolledBack() {} }
If you don't want to extend a Spring class, you can configure a test-runner instead using annotations. Spring also supports many of the other major unit-testing frameworks and older versions of JUnit.
相关问答
更多-
TCP/IP模型是一个________。[2023-10-02]
a -
pm2 deploy工具提供了命令revert 。 所以,你可以这样做: pm2 deploy ecosystem.json revert 这会将您的应用“回滚”到之前的部署。 您还可以指定上次部署还原的数量。 另请参阅命令[ref]与list , curr或prev结合使用: https://github.com/Unitech/PM2/blob/0.14.7/ADVANCED_README.md#deployment-options The tool pm2 deploy provides the c ...
-
下列中不属于面向对象的编程语言的是?[2022-05-30]
a -
@Test之后的回滚事务(Rollback transaction after @Test)[2023-02-14]
只需在测试之上添加@Transactional注释: @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(locations = {"testContext.xml"}) @Transactional public class StudentSystemTest { 默认情况下,Spring将会围绕你的测试方法和@Before / @After回调开始一个新的事务,最后回滚。 默认情况下,在上下文中有一些事务管理器就足够了。 来自 ... -
我发现要做到这一点的最佳方式是: 开始测试 开始交易 (可选)使用类似DBUnit的方式加载测试需要的任何DB数据 运行测试 回滚事务 请注意,所有数据库操作都发生在同一个事务中。 由于此事务在测试结束时回滚(即使引发异常),数据库在测试结束时应始终处于与开始时相同的状态。 Spring提供了一些真正有用的类,它们将负责为每个测试启动和回滚事务。 如果您使用的是Spring&JUnit4,并且不介意您的测试类需要扩展Spring类,那么最简单的选择可能是扩展AbstractTransactionalJUni ...
-
如何回滚具体迁移?(How to rollback a specific migration?)[2023-06-25]
rake db:rollback STEP=1 是一种方法来执行此操作,如果要回滚的迁移是最后一个应用程序。 您可以替换1,但是您希望返回的许多迁移。 例如: rake db:rollback STEP=5 还会回滚以后发生的所有迁移(4,3,2和1)。 正如意见中所建议的: 为了回滚具体的迁移用途: rake db:migrate:down VERSION=20100905201547 rake db:rollback STEP=1 Is a way to do this, if the migr ... -
只需在没有BEGIN..END的情况下从SQL * Plus执行代码; insert into sometable values (1, 1, 'test', 'test', 1, 'a', 1, 1, 1, 'test', 'test', 'test', 'test', 1); select * from sometable where id = 1; ROLLBACK; Just execute your code from SQL*Plus without BEGIN..END; insert ...
-
最后我得到了答案, 开始了 bin/cake migrations rollback -t
非常感谢SO :) Finally i got the answer, here we go bin/cake migrations rollback -t Thanks Anyways to SO :) -
回滚ORMapper查询(Rollback ORMapper Queries)[2023-04-12]
使用“SqlSession”时,MyBatis允许回滚,就是你使用spring依赖注入片,它会在方法完成时自动提交你的事务。 你有几个选择,其中包括 注入依赖项的模拟。 有一些摇摆的图书馆可以帮助解决这个问题。 像Mockito一样, 这是关于Spring Mockito的一个很好的问题 。 这将测试您的Java中的业务逻辑,但不测试您的实际查询。 提交您的查询,并在测试运行后删除您的数据。 这是我们采用的方法,因为它也测试了我们的数据库。 你显然需要一个数据库的测试实例,而有些人却没有。 您可以尝试为在M ... -
根据我的理解,您将在测试方法中手动创建一个新的独立Spring上下文,该方法在初始化期间创建表。 由于该上下文使用自己的事务管理器和数据源,因此它不会受到@Rollback注释的影响 - 在整个测试类定义的(隐式)spring上下文的上下文中处理该注释。 另请注意,在某些DB中,您无法回滚CREATE命令(但不确定Derby)。 更新 另一个问题是,当您通过datasource.getConnection()获得连接时,实际上并未使用事务管理器。 从DataSourceTransactionManager文 ...