Load Balancing for My Steem APIs

I have added a Load Balancing through CloudFlare Worker to my list of Free APIs at https://steemyy.com/list-of-api.php

For example, previously you would call:

https://steemyy.com/api/steemit/delegatees/?cached&id=justyy

Now, you can call the API via Load Balancer:

https://api.justyy.workers.dev/api/steemit/delegatees/?cached&id=justyy

The Load Balancer will first make a query to my 11 API servers and the first server that returns wins the request - which will be forwarded by the Load Balancer.

Using Load Balancer improves the user experience and also the throughput. It allows you to scale your application horizaontally.

https://i0.wp.com/gbhackers.com/wp-content/uploads/2018/12/Load-Balancer.jpg?fit=759%2C387&ssl=1

image.png


Every little helps! I hope this helps!

Steem On!~

If you like my work, please consider voting for me, thanks!
https://steemit.com/~witnesses type in justyy and click VOTE



Alternatively, you could proxy to me if you are too lazy to vote!

Also: you can vote me at the tool I made: https://steemyy.com/witness-voting/?witness=justyy

Visit me at: https://steemyy.com


This page is synchronized from the post: ‘Load Balancing for My Steem APIs’

Enabling tags_api requires a Replay

I have experimented this twice.. and to be honest, it isn’t that great. As both time, I ended up restoring the RPC node from a snapshot and do a replay.

So, here is the story. I got a feedback sometime ago saying that my RPC node https://api.justyy.com hasn’t enabled the tags_api

Last month, i experimented by adding tags_api to the config.ini and restarted the steemd but it didn’t work as expected, and somehow it damaged the blockchain files and then I restored a previous snapshot and ended up replaying for a couple of hours.

Today, I was told that i may need to add tags as well, which I thought it would make perfect sense, and thus I have added both tags and tags_api. But again, it didn’t work as expected.

image.png

I then restart the steemd but again it was not able to make it. Unfortunately I had to restore a snapshot that I luckily took prior to the testing.


Every little helps! I hope this helps!

Steem On!~

If you like my work, please consider voting for me, thanks!
https://steemit.com/~witnesses type in justyy and click VOTE



Alternatively, you could proxy to me if you are too lazy to vote!

Also: you can vote me at the tool I made: https://steemyy.com/witness-voting/?witness=justyy

Visit me at: https://steemyy.com


This page is synchronized from the post: ‘Enabling tags_api requires a Replay’

Keychain doesn't work for Blurt

Just to say hi!

————- well this isn’t sucessfull….
As this post should go to Blurt chain… but somehow using Keychain it is posted on STEEM.

I guess this is caused by the Node URL in keychain is still pointing to STEEM instead of Blurt.

image.png


This page is synchronized from the post: ‘Keychain doesn’’t work for Blurt’

Adding a RPC Node in Asian (Tokyo)

As you probably know, my RPC node https://api.justyy.com is located in Germany. Thus now I have added a second RPC node in Asian Pacific (Tokyo). This is useful for steemians from China.

The node: https://api.steemyy.com

It is based on AWS instance. And only the HTTPS is supported.

image.png

https://steemyy.com/node-status.php
image.png

@steemcurator01


Every little helps! I hope this helps!

Steem On!~

If you like my work, please consider voting for me, thanks!
https://steemit.com/~witnesses type in justyy and click VOTE



Alternatively, you could proxy to me if you are too lazy to vote!

Also: you can vote me at the tool I made: https://steemyy.com/witness-voting/?witness=justyy

Visit me at: https://steemyy.com


This page is synchronized from the post: ‘Adding a RPC Node in Asian (Tokyo)’

How to SSH to Remote Host using the Priviate/Public Keys Authentication?

Password Authentication is not secure. Your password may be too simple to crack or acidentally may be recorded or leaked. Therefore, it is a good practice to configure the authentication without using Password.

SSH using Public/Private Key Pair


The Simple Idea to replace Password Authentication is to Use a Private/Public Keys (Asymmetrical Cryptography Algorithm e.g. RSA). Let’s say you are on Host A and want to login to Host B. All you need to do is the following steps:

Generate a Public/Private Key Pair on Host A


You can run ssh-keygen -t rsa to generate a key pair. Just press Enter when questions are prompted.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
$ ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/home/user/.ssh/id_rsa):
Created directory '/home/user/.ssh'.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/user/.ssh/id_rsa.
Your public key has been saved in /home/user/.ssh/id_rsa.pub.
The key fingerprint is:
XXXXXXXXXXXXXXXXXXXXXX user@HostA
The key's randomart image is:
+---[RSA 2048]----+

| =B+o++. |
| XXXXXXXX.|
| . .o+XXXX*|
| ..o @ o o|
| XXXXX . . |
| .o=.B . |
| o.* |
| XXXX |
| o |
+----[SHA256]-----+

As you can see, in the /home/user directory, there will be two files: private key id_rsa which you should not give it to anybody else. And id_rsa.pub which you will need to give it to your destination Host.

Configure Authorized Keys on Destination Host


Then, on the Host server B, in the directory /home/user/.ssh/, we need to create a file if it is not there i.e. authorized_keys and you need to copy the content of the public key file namely id_rsa.pub and append to the end of the file. Each line will be one authorized key.

That is it. When this is all set, from Host A, you can directly SSH or scp to the Host B.

Avoid Permissions Pitfall


However, if it is not working, most of the time it is due to incorrect file permissions. You need to run the following on Host B.

1
2
chmod 700 ~/.ssh
chmod 600 ~/.ssh/authorized_keys

Also, the home directory need to be set correctly:

1
chmod g-w,o-w ~

Debugging SSH Login Problems


You can use ssh -v to see the verbose information which might help you identify the problem.

1
2
3
debug1: Next authentication method: publickey
debug1: Offering public key: RSA SHA256:XXXXXXXXXXXXXXX /home/user/.ssh/id_rsa
debug1: Server accepts key: pkalg rsa-sha2-512 blen 279

Every little helps! I hope this helps!

Steem On!~

Reposted to The Blog of Computing

If you like my work, please consider voting for me, thanks!
https://steemit.com/~witnesses type in justyy and click VOTE



Alternatively, you could proxy to me if you are too lazy to vote!

Also: you can vote me at the tool I made: https://steemyy.com/witness-voting/?witness=justyy

Visit me at: https://steemyy.com


This page is synchronized from the post: ‘How to SSH to Remote Host using the Priviate/Public Keys Authentication?’

How do you Unit Test a Simple Getter and Setter Interface in Java?

Usually, we unit tests the logics. An interface is without implementation details. A interface is just a binding a contract, but still, we can use Mockito to mock the interface, and test it.

For example, given the following simple Setter and Getter Interface:

1
2
3
4
interface GetAndSet {
void setValue(String name);
String getValue();
}

We can test it like this - thanks to the Mockito mocking framework in Java. We use doAnswer method to intercept the invokation of a interface method i.e. setter, then at the time, we mock the getter.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
package com.helloacm;

import lombok.val;
import org.junit.jupiter.api.Test;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.mockito.Mockito.*;

interface GetAndSet {
void setValue(String name);
String getValue();
}

public class ExampleTest {
@Test
public void test_simple_getter_setter_interface() {
val instance = mock(GetAndSet.class);

doAnswer(invocation ->; {
// or use invocation.getArgument(0);
val name = (String)invocation.getArguments()[0];
when(instance.getValue()).thenReturn(name);
return null;
}).when(instance).setValue(anyString());

instance.setValue("HelloACM.com");
assertEquals("HelloACM.com", instance.getValue());
}
}

If the method we are mocking is not void - we can use when. For example:

1
2
3
when(instance.getValue()).thenAnswer(innocation -> {
return "Hello";
});

Every little helps! I hope this helps!

Steem On!~

Reposted to The Blog of Computing

If you like my work, please consider voting for me, thanks!
https://steemit.com/~witnesses type in justyy and click VOTE



Alternatively, you could proxy to me if you are too lazy to vote!

Also: you can vote me at the tool I made: https://steemyy.com/witness-voting/?witness=justyy

Visit me at: https://steemyy.com


This page is synchronized from the post: ‘How do you Unit Test a Simple Getter and Setter Interface in Java?’

Your browser is out-of-date!

Update your browser to view this website correctly. Update my browser now

×